Файл: _rootinc/functions.inc.php
Строк: 23467
<?
###########################################
# >> Служебные переменные и константы #
###########################################
$_registrators[activeby] = "active.by";
$_registrators[cnic] = "centralnic.com";
$_registrators[directi] = "directI";
$_registrators[dotfm] = "dot.fm";
$_registrators[ppua] = "drs.ua";
$_registrators[epag] = "epag.net";
$_registrators[ficora] = "ficora.fi";
$_registrators[freehost] = "freehost.com.ua";
$_registrators[gfx] = "gfx.kz";
$_registrators[hosterby] = "hoster.by";
$_registrators[hostmaster] = "hostmaster.net.ua (RRP)";
$_registrators[hostmasterepp] = "hostmaster.net.ua (EPP)";
$_registrators[internetbs] = "internet.bs";
$_registrators[internetx] = "internetx.de";
$_registrators[namecheap] = "namecheap.com";
$_registrators[naunet] = "naunet.ru";
$_registrators[networking4all] = "networking4all.com";
$_registrators[nicdpua] = "nic.dp.ua";
#$_registrators[niclv] = "nic.lv";
$_registrators[nicru] = "nic.ru";
$_registrators[onlinenic] = "onlinenic.com";
$_registrators[pskz] = "ps.kz";
$_registrators[r01] = "r01.ru & centrohost.ru & reghouse.ru & ua-hosting.org";
$_registrators[regru] = "reg.ru & 2domains.ru & ua-hosting.org";
$_registrators[rootpanel] = "rootpanel.ru api";
$_registrators[rrpproxy] = "rrpproxy.net";
$_registrators[started] = "started.ru";
$_registrators[subreg] = "subreg.cz";
$_registrators[todaynic] = "todaynic.com";
$_registrators[ukrnames] = "ukrnames.com";
$_registrators[webnames] = "webnames.ru";
$_registrators[websitews] = "website.ws";
$_registrators[mail] = "e-mail";
$_payments[partner] = "Партнерский счет";
$_payments[balance] = "Внутренний баланс";
$_payments[kvitancii] = "Квитанции для физ. лиц";
$_payments[scheta] = "Счета для юр. лиц";
$_payments[dop] = "Дополнительные способы оплаты";
$_payments[twoco] = "2Checkout.com";
$_payments[twopay] = "2pay.ru";
$_payments[a1lite] = "A1Pay.ru / A1Lite";
$_payments[assist] = "Assist.ru";
$_payments[authorize] = "Authorize.Net (SIM / Card Not Present)";
$_payments[copayco] = "CoPAYCo.com";
$_payments[egold] = "E-gold.com";
$_payments[easypay] = "EasyPay.by";
$_payments[easysoft] = "EasySoft.com.ua";
$_payments[intellectmoney] = "IntellectMoney.ru";
$_payments[ikass] = "InterKassa.com";
$_payments[kkbkz] = "Казкоммерцбанкк / epay.kkb.kz";
$_payments[kzmkz] = "KZM / kzm.kz";
$_payments[liberty] = "LibertyReserve.com";
$_payments[liqpay] = "LiqPay.com";
$_payments[monexy] = "MoneXy.com";
$_payments[moneyua] = "Money.ua";
$_payments[netcard] = "NetCard.az";
$_payments[netmoney] = "NetMoney.az";
$_payments[onpay] = "OnPay.ru";
$_payments[paypal] = "PayPal (IPN)";
$_payments[payu] = "PayU.ua";
$_payments[perfectmoney] = "PerfectMoney.com";
$_payments[portmone] = "Portmone.com";
$_payments[privatbank] = "ПриватБанк (интернет-эквайринг)";
$_payments[p24] = "Приват24 (интернет-эквайринг)";
$_payments[qiwi] = "QIWI Кошелек / ishop.qiwi.ru";
$_payments[qiwikz] = "QIWI Казахстан / qiwi.kz";
$_payments[rupay] = "RBKMoney.ru";
$_payments[robox] = "RoboXchange.com";
$_payments[smscoin] = "SMSCoin.ru / СМС:Банк";
$_payments[sprypay] = "SpryPay.ru";
$_payments[superlend] = "SuperLend.ru";
$_payments[taulinkkz] = "Таулинк Казахстан";
$_payments[telemoney] = "TeleMoney.ru";
$_payments[upc] = "UPC.ua";
$_payments[webmoney] = "WebMoney.ru";
$_payments[webpay] = "WebPay.by";
$_payments[zpay] = "Z-Payment.ru";
$_payments[pro] = "ЯД мерчант";
$_payments[yandex] = "Яndex.Деньги";
$_pays[ikass][select1checks] = array("alertpay" => "AlertPay (USD)", "bankophone" => "Bank-O-Phone (BOP UAH)", "egold" => "E-Gold (E-Gold USD)", "easypay" => "EasyPay (EP BYR)", "libertyz" => "Liberty Reserve (LR USD)", "libertye" => "Liberty Reserve (LR EUR)", "limonexwmz" => "Limonex (Limonex WMZ)", "limonexumz" => "Limonex (Limonex UM-USD)", "limonexumu" => "Limonex (Limonex UM-UAH)", "limonexeg" => "Limonex (Limonex E-GOLD)", "liqpayz" => "LiqPay (LP USD)", "liqpayr" => "LiqPay (LP RUR)", "liqpayu" => "LiqPay (LP UAH)", "liqpaye" => "LiqPay (LP EUR)", "monexyr" => "MoneXy (MoneXy RUR)", "monexyu" => "MoneXy (MoneXy UAH)", "monexye" => "MoneXy (MoneXy EUR)", "monexyz" => "MoneXy (MoneXy USD)", "moneymailr" => "MoneyMail (MM RUR)", "moneymaile" => "MoneyMail (MM EUR)", "moneymailz" => "MoneyMail (MM USD)", "moneybookers" => "Moneybookers (MB USD)", "pincodez" => "PIN-CODE (USD)", "paxum" => "Paxum (USD)", "paypal" => "PayPal (USD)", "pecunix" => "Pecunix (Pecunix USD)", "perfectmoneye" => "PerfectMoney (PM EUR)", "perfectmoneyz" => "PerfectMoney (PM USD)", "privat24e" => "Privat24 (P24 EUR)", "privat24z" => "Privat24 (P24 USD)", "privat24lu" => "Privat24 (P24.L UAH )", "privat24u" => "Privat24 (P24 UAH)", "privatbank" => "PrivatBank (UAH)", "w1qiwir" => "Qiwi Кошелек (RUR)", "w1qiwiz" => "Qiwi Кошелек (USD)", "rbkmoneyx" => "RBK Money (RBK RUR)", "rbkmoney" => "RBK Money (RBK RUR)", "smscoin" => "SMSCoin (USD)", "telemoneyr" => "Telemoney (TM RUR)", "w1ukashz" => "Ukash (USD)", "ukrmoneyr" => "UkrMoney (UM RUR)", "ukrmoneye" => "UkrMoney (UM EUR)", "ukrmoneyz" => "UkrMoney (UM USD)", "ukrmoneyu" => "UkrMoney (UM UAH)", "unicard" => "Unikarta (UK USD)", "liqpaycardwu" => "Visa (World) (UAH)", "liqpaycardwr" => "Visa (World) (RUR)", "liqpaycardwz" => "Visa (World) (USD)", "liqpaycardwe" => "Visa (World) (EUR)", "liqpaycardu" => "Visa, Mastercard (СНГ) (UAH)", "liqpaycardr" => "Visa, Mastercard (СНГ) (RUR)", "liqpaycardz" => "Visa, Mastercard (СНГ) (USD)", "liqpaycarde" => "Visa, Mastercard (СНГ) (EUR)", "wmnotez" => "WMnote (WMZ)", "wmnotee" => "WMnote (WME)", "wmnotel" => "WMnote (LVL)", "webcreds" => "WebCreds (WC RUR)", "webmoneyr" => "WebMoney (WMR)", "webmoneye" => "WebMoney (WME)", "webmoneyz" => "WebMoney (WMZ)", "webmoneyu" => "WebMoney (WMU)", "webmoneyg" => "WebMoney (WMG)", "webmoneyb" => "WebMoney (WMB)", "superlendwmz" => "WebMoney Credits (WMZ)", "eurobank" => "Wire Transfer (USD)", "zpaymentr" => "Z-payment (ZP RUB)", "imoney" => "iMoney (iMoney UAH)", "w1alfaclick" => "Альфа-Клик (RUB)", "w1alfaclickz" => "Альфа-Клик (USD)", "alfabank" => "Альфабанк (Альфаклик) (RUR)", "rusbank" => "Банки России (RUR)", "ukrbank" => "Банки Украины (UAH)", "vtbbank" => "ВТБ24 (Телебанк) (RUR)", "w1contactr" => "Денежные переводы «CONTACT» (RUR)", "w1contactz" => "Денежные переводы «CONTACT» (USD)", "w1anelikr" => "Денежные переводы «Anelik» (RUR)", "w1anelikz" => "Денежные переводы «Anelik» (USD)", "w1liderr" => "Денежные переводы «ЛИДЕР» (RUR)", "w1liderz" => "Денежные переводы «ЛИДЕР» (USD)", "w1unistreamr" => "Денежные переводы «Юнистрим» (RUR)", "w1unistreamz" => "Денежные переводы «Юнистрим» (USD)", "w1u" => "Единый кошелек (W1 UAH)", "w1e" => "Единый кошелек (W1 EUR)", "w1z" => "Единый кошелек (W1 USD)", "w1r" => "Единый кошелек (W1 RUR)", "mobw" => "Мобильный кошелек (Mobw RUR)", "w1beelinez" => "Мобильный платеж «Билайн» (USD)", "w1beeliner" => "Мобильный платеж «Билайн» (RUR)", "w1mtsr" => "Мобильный платеж «МТС» (RUR)", "w1mtsz" => "Мобильный платеж «МТС» (USD)", "w1megafonz" => "Мобильный платеж «Мегафон» (USD)", "w1megafonr" => "Мобильный платеж «Мегафон» (RUR)", "nsmep" => "НСМЕП (НСМЭП UAH)", "w1ruspostz" => "Почта России (USD)", "w1ruspostr" => "Почта России (RUR)", "w1cashterminalz" => "Салоны связи и гипермаркеты электроники (USD)", "w1cashterminalr" => "Салоны связи и гипермаркеты электроники (RUR)", "sbrf" => "Сбербанк РФ (RUR)", "liqpayterminalu" => "Терминалы Приватбанка (UAH)", "w1terminalz" => "Терминалы России (USD)", "w1terminalr" => "Терминалы России (RUR)", "w1terminalu" => "Терминалы Украины (UAH)", "wmterminalu" => "Терминалы Украины (UAH)", "terminalu" => "Терминалы Украины (UAH)", "yandexmoneyapi" => "Яндекс.Деньги (YMR)", "yandexdengir" => "Яндекс.Деньги (Y.M RUR)");
$_pays[onpay][select1checks] = array("ATM" => "Банкоматы", "BOC" => "Виртуальная карта Beeline", "BTR" => "Банковский перевод RUR", "BVC" => "Visa MasterCard (BVC)", "CCT" => "World Visa/Mastercard", "DMR" => "Деньги@mail.ru", "EUR" => "Банковский перевод EUR", "EVS" => "Евросеть, RUR", "HBK" => "Терминалы Элекснет (Handybank)", "JKH" => "Оплата ЖКХ", "LIE" => "Visa MasterCard EUR (LiqPay)", "LIQ" => "Visa MasterCard RUR (LiqPay)", "LIU" => "Visa MasterCard UAH (LiqPay)", "LIZ" => "Visa MasterCard USD (LiqPay)", "LRU" => "Liberty Reserve", "MBZ" => "Кошелек Onpay", "MG1" => "Мегафон", "MMR" => "Moneymail.ru", "MOB" => "Мобильные платежи", "MT1" => "МТС", "NVP" => "Терминалы Новоплат", "OCE" => "Visa MasterCard (OCE)", "OSP" => "Терминалы QIWI (ОСМП)", "POT" => "Почтовый перевод", "PPL" => "PayPal", "PRV" => "ПриватБанк", "RBK" => "RBK money", "TCR" => "Visa MasterCard RUR (TCR)", "TRS" => "Системы денежных переводов, RUR", "UNR" => "Visa/Mastercard/JCB/DC", "USD" => "Банковский перевод USD", "WMB" => "Webmoney WMB", "WME" => "Webmoney WME", "WMR" => "Webmoney WMR", "WMU" => "Webmoney WMU", "WMZ" => "Webmoney WMZ", "YDX" => "Яндекс.Деньги");
$_menus[bills] = "Счета";
$_menus[orders] = "Заказы";
$_menus[domains] = "Домены";
$_menus[shop] = "Товары/Услуги";
$_menus[partner] = "Партнер";
$_menus[tickets] = "Тикеты";
$_menus[profile] = "Профайл";
$_menus[settings] = "Настройки";
$_menus[maillogs] = "Почта";
$_menus[catalog] = "Каталог";
$_menus[whois] = "Whois";
$_menus[logout] = "Выйти";
$_menus[orderHosting] = "Заказать хостинг";
$_menus[orderReseller] = "Заказать реселлинг";
$_menus[orderVds] = "Заказать VDS";
$_menus[orderDedicated] = "Заказать сервер";
$_menus[orderVpn] = "Заказать VPN";
$_menus[orderSsh] = "Заказать SSH";
$_menus[orderDomains] = "Заказать домен";
$_menus[orderDomainsOpt] = "Домены оптом";
$_menus[orderShop] = "Заказать товар/услугу";
$_vids["Хостинг"] = "hosting";
$_vids["Реселлинг"] = "reseller";
$_vids["VPS/VDS"] = "vds";
$_vids["Выделенный сервер"] = "dedicated";
$_vids["VPN"] = "vpn";
$_vids["SSH"] = "ssh";
function valid_email($eemail,$checkMX=false) {
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)) {
list($username, $domain) = mb_split("@", $eemail);
if ($checkMX) {
if (function_exists("getmxrr")) {
$mxRes = getmxrr($domain, $mxhost);
} else {
$mxRes = 1;
}
if ($mxRes) {
return true;
} else {
$f = @fsockopen($domain, 25, $errno, $errstr, 5);
if ($f) {
@fclose($f);
return true;
} else {
return false;
}
}
} else {
return true;
}
} else {
return false;
}
}
function sendmail($msgto='',$msgfromname,$msgfrom,$msgsubj,$msgtext,$attachfile='',$attachfile2='',$contenttype='text',$encoding='utf-8') {
if ($msgto) {
$mailFrom = GetSetting("mailFrom");
$replyTo = $msgfrom;
if ($mailFrom) { $msgfrom = $mailFrom; }
$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');
$mailSMTPSetSender = GetSetting('mailSMTPSetSender');
if ($mailSMTPSetSender) {
$mail->Sender = $msgfrom;
}
$mailSMTPAuth = GetSetting('mailSMTPAuth');
if ($mailSMTPAuth == "POPbeforeSMTP") {
$mailPOPServer = GetSetting('mailPOPServer');
$mailPOPPort = GetSetting('mailPOPPort');
$mailPOPUser = GetSetting('mailPOPUser');
$mailPOPPassword = decodePwd(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 = decodePwd(GetSetting('mailSMTPPassword'));
}
}
$mail->From = $msgfrom;
$mail->FromName = htmlDecode($msgfromname);
$mail->AddAddress($msgto);
$mail->Subject = htmlDecode($msgsubj);
$mail->Body = htmlDecode($msgtext);
$mail->AddReplyTo($replyTo);
if ($attachfile and @file_exists($attachfile)) {
$mail->AddAttachment($attachfile);
}
if ($attachfile2 and @file_exists($attachfile2)) {
$mail->AddAttachment($attachfile2);
}
if($mail->Send()) {
return 1;
} else {
return 0;
}
} else {
return 0;
}
}
function generatePassword($length = 8, $withSpec = 0, $withoutNumbers = 0) {
// start with a blank password
$password = "";
if ($withoutNumbers) {
// define possible characters
$possible = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
} else {
// 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 and !$withoutNumbers) {
$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" or $orderType == "ssh") {
$r = @mysql_query("select DISTINCT t2.login, t2.* from orders as t1, users as t2, tarifs as t3 where t1.archived=0 and 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 u.login, u.* from orders as o, users as u where o.archived=0 and u.id=o.uid and o.serverid='$serverid' order by u.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;
if ($do == "itemslist") {
$perPage = "300";
} else {
$perPage = GetSetting("perpage_".$do);
}
$pages = ceil($rows/$perPage);
if (!$page) {
if ($_SESSION[$do."Page"]) {
$page = $_SESSION[$do."Page"];
} else {
$page = 1;
}
}
if ($page > $pages or $page < 1) { $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 MakePartnersProcentsByBillId($id) {
$partnerEnable=GetSetting("partnerEnable");
$bill = GetBillById($id);
if ($partnerEnable and $bill->id) {
$partnerProcentAllOrders=GetSetting("partnerProcentAllOrders");
if ($partnerProcentAllOrders or (!$partnerProcentAllOrders and GetBillPayedCountByUserId($bill->uid) == 1)) {
$userReferal=GetUserById($bill->uid);
$userForMoney=GetUserById($userReferal->referal);
if ($userForMoney->id) {
$partnerType = GetSetting("partnerType");
$partnerLevels = GetSetting("partnerLevels");
$referalsCount = GetUserReferalsCount($userForMoney->id);
if ($bill->money_host) {
if ($bill->host_id and !$bill->newtarif and !$bill->newaddons) {
$order = GetOrderById($bill->host_id);
$tarif = GetTarifById($order->tarif);
if ($tarif->vid) { $orderTypes[] = $tarif->vid; }
}
else if ($bill->host_id and $bill->newtarif) {
$tarif = GetTarifById($bill->newtarif);
if ($tarif->vid) { $orderTypes[] = $tarif->vid; }
}
}
if ($bill->money_domain) { $orderTypes[] = "domains"; }
if ($bill->money_addons) { $orderTypes[] = "addons"; }
if ($bill->money_shop) { $orderTypes[] = "shop"; }
if ($bill->money and !$bill->addfunds) { $orderTypes[] = "other"; }
$moneyByReferal = 0;
$moneyFromReferal = 0;
while (list($k,$v) = @each($orderTypes)) {
if ($partnerType == "withReferalCount") { $sql = "and $referalsCount >= refsCountMin and $referalsCount <= refsCountMax"; } else { $sql = ""; }
$percent = @mysql_query("select percentsLevel1 from partner_percents where uid='$userForMoney->id' and (type='all' or type='$v') $sql") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($percent) > 0) { $percent = mysql_fetch_object($percent); $percent = $percent->percentsLevel1; }
else {
$percent = @mysql_query("select percentsLevel1 from partner_percents where uid='0' and (type='all' or type='$v') $sql") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($percent) > 0) { $percent = mysql_fetch_object($percent); $percent = $percent->percentsLevel1; } else { $percent = 0; }
}
if ($percent > 0) {
if ($v == "hosting" or $v == "reseller" or $v == "vds" or $v == "dedicated" or $v == "vpn" or $v == "ssh") { $moneyFromReferal += ($bill->money_host/100)*$percent; $moneyByReferal += $bill->money_host;}
else if ($v == "domains") { $moneyFromReferal += ($bill->money_domain/100)*$percent; $moneyByReferal += $bill->money_domain;}
else if ($v == "addons") { $moneyFromReferal += ($bill->money_addons/100)*$percent; $moneyByReferal += $bill->money_addons;}
else if ($v == "shop") { $moneyFromReferal += ($bill->money_shop/100)*$percent; $moneyByReferal += $bill->money_shop;}
else if ($v == "other") { $moneyFromReferal += ($bill->money/100)*$percent; $moneyByReferal += $bill->money;}
}
}
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());
@mysql_query("insert into partner_stats (uid,referal,dt,sumin,sumpartner) VALUES('$userForMoney->id','$bill->uid',NOW(),'$moneyByReferal','$moneyFromReferal')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
addUserLog($userForMoney->id, "moneyIn", "Referal percents (level 1) (user id #$userReferal->id): $moneyFromReferal".CURAS." (bill id #$bill->id)");
################### level 2 ###################################
if ($partnerLevels == "2") {
$userForMoney2=GetUserById($userForMoney->referal);
if ($userForMoney2->id) {
$referalsCount2 = GetUserReferalsCount($userForMoney2->id);
$moneyByReferal2 = 0;
$moneyFromReferal2 = 0;
reset($orderTypes);
while (list($k,$v) = @each($orderTypes)) {
if ($partnerType == "withReferalCount") { $sql = "and $referalsCount2 >= refsCountMin and $referalsCount2 <= refsCountMax"; } else { $sql = ""; }
$percent = @mysql_query("select percentsLevel2 from partner_percents where uid='$userForMoney2->id' and (type='all' or type='$v') $sql") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($percent) > 0) { $percent = mysql_fetch_object($percent); $percent = $percent->percentsLevel2; }
else {
$percent = @mysql_query("select percentsLevel2 from partner_percents where uid='0' and (type='all' or type='$v') $sql") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($percent) > 0) { $percent = mysql_fetch_object($percent); $percent = $percent->percentsLevel1; } else { $percent = 0; }
}
if ($percent > 0) {
if ($v == "hosting" or $v == "reseller" or $v == "vds" or $v == "dedicated" or $v == "vpn" or $v == "ssh") { $moneyFromReferal2 += ($bill->money_host/100)*$percent; $moneyByReferal2 += $bill->money_host; }
else if ($v == "domains") { $moneyFromReferal2 += ($bill->money_domain/100)*$percent; $moneyByReferal2 += $bill->money_domain; }
else if ($v == "addons") { $moneyFromReferal2 += ($bill->money_addons/100)*$percent; $moneyByReferal2 += $bill->money_addons; }
else if ($v == "shop") { $moneyFromReferal2 += ($bill->money_shop/100)*$percent; $moneyByReferal2 += $bill->money_shop; }
else if ($v == "other") { $moneyFromReferal2 += ($bill->money/100)*$percent; $moneyByReferal2 += $bill->money; }
}
}
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());
@mysql_query("insert into partner_stats (uid,referal,dt,sumin,sumpartner) VALUES('$userForMoney2->id','$bill->uid',NOW(),'$moneyByReferal2','$moneyFromReferal2')") 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 #$bill->id)");
}
} else {
@mysql_query("update users set referal=0 where id='$userForMoney->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
}
################### 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());
}
}
}
}
function ProcessOrderByBillId($id,$needTestHost=0) {
global $full_home_path, $full_www_path, $dbhost, $dbuser, $dbpass, $dbname, $HYPERVM_DEFAULT_OS, $SOLUSVM_DEFAULT_OS, $ip;
$bill = GetBillById($id);
if ($bill->host_id and !$bill->newtarif and !$bill->newserver and !$bill->newslots and !$bill->newaddons) {
$order = GetOrderById($bill->host_id);
$tarif = GetTarifById($order->tarif);
$server = GetServers($order->serverid);
if ($needTestHost and $order->testPeriod) {
createUser($bill->host_id);
return true;
}
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 or $order->status == "3")) {
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 or $order->status == "3") 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 or $order->status == "3") 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 ($bill->deleteaddons) {
$orderAddons=@mb_split(":x:", $order->addons);
$deleteAddons=@mb_split(":x:", $bill->deleteaddons);
while (list($q,$w) = @each($deleteAddons)) {
if ($w) {
reset($orderAddons);
while (list($qq,$ww) = @each($orderAddons)) {
if ($ww) {
if ($w == $ww) { unset($orderAddons[$qq]); break; }
}
}
}
}
$orderAddons = @join(":x:",$orderAddons);
@mysql_query("update orders set addons='$orderAddons' where id='$bill->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
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 ($server->type == "rootpanel" and $tarif->autosuspend) {
renewUser($bill->host_id, $bill->host_srok);
@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 == "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);
$history = "<B>Тариф:</B> $newTarif->name";
if ($order->domain) { $history .= ", <B>домен:</B> $order->domain";}
addUserLog($order->uid,'changetarif',"For order ID #$order->id, $order->domain, from $oldTarif->name to $newTarif->name");
@mysql_query("update orders set tarif='$bill->newtarif',history='$history' 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->newserver) {
$order = GetOrderById($bill->host_id);
if (IsAccessibleChangeServerForOrder($order->id,$bill->newserver)) {
$tarif = GetTarifById($order->tarif);
$oldServer = GetServers($order->serverid);
$newServer = GetServers($bill->newserver);
addUserLog($order->uid,'changeserver',"For order ID #$order->id, $order->domain, $tarif->name, from $oldServer->place to $newServer->place");
@mysql_query("update orders set serverid='$bill->newserver',changeServerCount=changeServerCount+1 where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
changeServer($order->id, $bill->newserver);
}
} else if ($bill->host_id and $bill->newslots) {
$order = GetOrderById($bill->host_id);
$tarif = GetTarifById($order->tarif);
addUserLog($order->uid,'changeslots',"For order ID #$order->id, $order->domain, $tarif->name, from $order->slots to $bill->newslots");
@mysql_query("update orders set slots='$bill->newslots' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
changeSlots($order->id, $bill->newslots);
} 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)) {
$oneAddon = GetAddonById($v);
if ($oneAddon->id) {
$currAddons[] = $v;
if ($oneAddon->type == "changeserverlimit") {
@mysql_query("update orders set changeServerBuyed=changeServerBuyed+$oneAddon->field1 where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
else if (preg_match("/solusvmextraip/ui",$oneAddon->textid)) {
addExtraIPs($order->id, 1);
}
}
}
$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->privacy and !$bill->transfer) {
$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());
if ($d->privacy) {
@mysql_query("update orders_domains set todateprivacy=DATE_ADD(NOW(),INTERVAL 12 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 or $d->status == "3")) {
$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);
@mysql_query("update orders_domains set status=1 where id='$bill->domain_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
}
}
else if ($bill->domain_id and $bill->transfer) {
$d = GetdomainById($bill->domain_id);
@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());
if ($d->privacy) {
@mysql_query("update orders_domains set todateprivacy=DATE_ADD(NOW(),INTERVAL 12 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 or $d->status == "3")) {
$period = $bill->domain_srok/12;
transferDomain($d->id, $period);
}
}
else if ($bill->domain_id and $bill->privacy) {
$d = GetdomainById($bill->domain_id);
$dt = mb_split("-",$d->todate);
$yearDomain = $dt[0]; $monthDomain = $dt[1]; $dayDomain = $dt[2];
$yearNow = date("Y"); $monthNow = date("m"); $dayNow = date("d");
if (($yearDomain - $yearNow) == 0) {
$privacyDate = $d->todate;
} else if (($yearDomain - $yearNow) == 1) {
if ((12-$monthNow+$monthDomain) == 12) {
if ($dayDomain > $dayNow) {
$privacyDate = $yearNow."-".$monthDomain."-".$dayDomain;
} else {
$privacyDate = $yearDomain."-".$monthDomain."-".$dayDomain;
}
}
else if ((12-$monthNow+$monthDomain) < 12) {
$privacyDate = $d->todate;
} else {
$privacyDate = $yearNow."-".$monthDomain."-".$dayDomain;
}
} else {
if ((12-$monthNow+$monthDomain) == 12) {
if ($dayDomain > $dayNow) {
$privacyDate = $yearNow."-".$monthDomain."-".$dayDomain;
} else {
$privacyDate = ($yearNow+1)."-".$monthDomain."-".$dayDomain;
}
}
else if ((12-$monthNow+$monthDomain) < 12) {
$privacyDate = ($yearNow+1)."-".$monthDomain."-".$dayDomain;
} else {
$privacyDate = $yearNow."-".$monthDomain."-".$dayDomain;
}
}
@mysql_query("update orders_domains set privacy=1,todateprivacy=$privacyDate where id='$bill->domain_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
updateDomainPrivacy($bill->domain_id, 1);
}
if ($bill->shop_id) {
$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 ((!$orderShop->status or $orderShop->status == "3") and ($shopItem->type == "avdesk" or $shopItem->type == "avdesk6" or $shopItem->type == "soft" or $shopItem->type == "ispmanagerlite" or $shopItem->type == "ispmanagerlitefull" or $shopItem->type == "ispmanagerlitetrial" or $shopItem->type == "ispmanagerpro" or $shopItem->type == "ispmanagerprofull" or $shopItem->type == "ispmanagerprotrial" or $shopItem->type == "vdsmanagerlinux" or $shopItem->type == "vdsmanagerlinuxfull" or $shopItem->type == "vdsmanagerfreebsd" or $shopItem->type == "vdsmanagerfreebsdfull" or $shopItem->type == "billmanagerstandart" or $shopItem->type == "billmanageradvanced" or $shopItem->type == "billmanagercorporate" or $shopItem->type == "dsmanager" or $shopItem->type == "dsmanagerfull" or $shopItem->type == "dnsmanagerfull" or $shopItem->type == "ipmanagerfull")) {
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" or $shopItem->type == "avdesk6" or $shopItem->type == "ispmanagerlite" or $shopItem->type == "ispmanagerlitefull" or $shopItem->type == "ispmanagerlitetrial" or $shopItem->type == "ispmanagerpro" or $shopItem->type == "ispmanagerprofull" or $shopItem->type == "ispmanagerprotrial" or $shopItem->type == "vdsmanagerlinux" or $shopItem->type == "vdsmanagerlinuxfull" or $shopItem->type == "vdsmanagerfreebsd" or $shopItem->type == "vdsmanagerfreebsdfull" or $shopItem->type == "billmanagerstandart" or $shopItem->type == "billmanageradvanced" or $shopItem->type == "billmanagercorporate" or $shopItem->type == "dsmanager" or $shopItem->type == "dsmanagerfull" or $shopItem->type == "dnsmanagerfull" or $shopItem->type == "ipmanagerfull") {
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 ((!$orderShop->status or $orderShop->status == "3") and ($shopItem->type == "avdesk" or $shopItem->type == "avdesk6" or $shopItem->type == "soft" or $shopItem->type == "ispmanagerlite" or $shopItem->type == "ispmanagerlitefull" or $shopItem->type == "ispmanagerlitetrial" or $shopItem->type == "ispmanagerpro" or $shopItem->type == "ispmanagerprofull" or $shopItem->type == "ispmanagerprotrial" or $shopItem->type == "vdsmanagerlinux" or $shopItem->type == "vdsmanagerlinuxfull" or $shopItem->type == "vdsmanagerfreebsd" or $shopItem->type == "vdsmanagerfreebsdfull" or $shopItem->type == "billmanagerstandart" or $shopItem->type == "billmanageradvanced" or $shopItem->type == "billmanagercorporate" or $shopItem->type == "dsmanager" or $shopItem->type == "dsmanagerfull" or $shopItem->type == "dnsmanagerfull" or $shopItem->type == "ipmanagerfull")) {
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());
}
}
function AddBillToQueue($id,$needTestHost=0) {
global $full_home_path, $full_www_path, $dbhost, $dbuser, $dbpass, $dbname;
@mysql_query("insert into orders_queue (bill_id,needTestHost) VALUES('$id','$needTestHost')") 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, $dbhost, $dbuser, $dbpass, $dbname, $HYPERVM_DEFAULT_OS, $SOLUSVM_DEFAULT_OS, $ip;
$bills = GetBillByIdWithAttached($id);
$orderProcessTypeHost = GetSetting("orderProcessTypeHost");
$orderProcessTypeDomain = GetSetting("orderProcessTypeDomain");
$orderProcessTypeShop = GetSetting("orderProcessTypeShop");
while ($bill = @mysql_fetch_object($bills)) {
if ($bill->status == "2" and $status == "1" and $bill->payed == "0000-00-00") {
@mysql_query("update bills set payed=NOW(),payeddt=NOW(),status='$status' where id='$bill->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
MakePartnersProcentsByBillId($bill->id);
}
else if ($bill->status == "2" and $status == "1" and $bill->payed != "0000-00-00") {
@mysql_query("update bills set status='$status' where id='$bill->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
else if ($bill->status == "1" and $status == "2") {
@mysql_query("update bills set status='$status' where id='$bill->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
else if (!$bill->status) {
if ($status == "1") {
$payed = "NOW()";
$payeddt = "NOW()";
} else {
$payed = "'0000-00-00'";
$payeddt = "'0000-00-00 00:00:00'";
}
@mysql_query("update bills set payed=$payed,payeddt=$payeddt,status='$status' where id='$bill->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($status == "1") {
MakePartnersProcentsByBillId($bill->id);
}
if ($bill->host_id) {
if ($orderProcessTypeHost) {
AddBillToQueue($bill->id);
} else {
ProcessOrderByBillId($bill->id);
}
}
else if ($bill->domain_id) {
if ($orderProcessTypeDomain) {
AddBillToQueue($bill->id);
} else {
ProcessOrderByBillId($bill->id);
}
}
else if ($bill->shop_id) {
if ($orderProcessTypeShop) {
AddBillToQueue($bill->id);
} else {
ProcessOrderByBillId($bill->id);
}
}
else {
ProcessOrderByBillId($bill->id);
}
if ($status) {
$user = GetUserById($bill->uid);
$tpl=GetTpl("pay_bill", $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
$sid=sprintf("%04d", $bill->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('{login}',$user->login,$template);
$template = str_replace('{bill_date}',mydate($bill->created),$template);
$template = str_replace('{pay_method}',"$merchant",$template);
$subject = str_replace('{login}',$user->login,$subject);
WriteMailLog($subject,$template,$user->id);
sendmail($user->email, $company_name, $manager_email, $subject, $template,'','',$tpl[type]);
sendmail($user->email2, $company_name, $manager_email, $subject, $template,'','',$tpl[type]);
$subject = "Duplicate: ".$subject;
$admEmails=GetAdminEmailsWhereTrueParam("sendpaybill");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em, '', $manager_email, $subject, $template,'','',$tpl[type]);
}
}
if (GetSetting("smsGateway")) {
$smsmsg = "Oplachen schet №$sid, user $user->login, via $merchant";
$admIds=GetAdminIdsWhereTrueParam("sms_sendpaybill");
while (list($i,$aid) = @each($admIds)) {
sendSMS('',$aid,$smsmsg);
}
}
}
}
}
}
function menu($enc = 'windows-1251') {
global $_lang, $languages, $_SESSION;
$user = GetUserById($_SESSION["userId"]);
$disallowedMenus = @mb_split(":x:",$user->disallowedMenus);
$lngUser = $_SESSION["userLang"];
$lngDefault = GetSetting("lngDefault");
$resPrint = "";
$resPrint .= "<H1 class=pagetitle>".$_lang[BillingTitle]."</H1><hr class=hr>";
$usersMenuShowType = GetSetting('usersMenuShowType');
if ($usersMenuShowType == "text") {
$usersMenuTextDelimiter = GetSetting('usersMenuTextDelimiter');
$isTextMenu = 1;
}
else if ($usersMenuShowType == "img") {
$usersMenuImgRowCount = GetSetting('usersMenuImgRowCount');
$usersMenuImgRowPadding = GetSetting('usersMenuImgRowPadding');
$usersMenuImgStrokiPadding = GetSetting('usersMenuImgStrokiPadding');
$usersMenuImgPosition = GetSetting('usersMenuImgPosition');
$usersMenuImgData = GetSetting('usersMenuImgData'); $usersMenuImgData = unserialize($usersMenuImgData);
$isImgMenu = 1;
}
else {
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>] <B class='menu_category'>".$_lang[BillingMenuId].":</b> <span class='menu_text'>".$_SESSION[userId]."</span><BR>"; }
$resPrint .= "<BR>";
print $resPrint;
return true;
}
if ($isTextMenu or $isImgMenu) {
$weSalesTypes = GetSetting("weSalesTypes");
$weSalesTypes = @mb_split("::",$weSalesTypes);
}
if ($isTextMenu) { $resPrint .= "<b class='menu_category'>".$_lang[BillingMenu].":</b> "; }
if ($isImgMenu) { $i = 1; $resPrint .= "<table cellpadding=0 cellspacing=0 border=0>"; }
### Счета
$idd = "bills";
$url = "billing.php?do=bills";
$text = $_lang[BillingMenuBills];
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='menu_link'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
###
### Заказы
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) or @in_array("ssh",$weSalesTypes)) {
$idd = "orders";
$url = "billing.php?do=orders";
$text = $_lang[BillingMenuOrders];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
}
###
### Домены
if (@in_array("domains",$weSalesTypes)) {
$idd = "domains";
$url = "billing.php?do=domains";
$text = $_lang[BillingMenuDomains];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
}
###
### Товары/услуги
if (@in_array("shop",$weSalesTypes)) {
$idd = "shop";
$url = "billing.php?do=shop";
$text = $_lang[BillingMenuShop];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
}
###
### Партнер
if (GetSetting("partnerEnable")) {
$idd = "partner";
$url = "billing.php?do=partner";
$text = $_lang[BillingMenuPartner];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
}
###
### Тикеты
if (GetSetting("ticketsEnable")) {
$idd = "tickets";
$url = "billing.php?do=tickets";
$text = $_lang[BillingMenuTickets];
if (IsNewTicketsForUser($_SESSION["userId"])) { $class="menu_link_highlight"; } else { $class = "menu_link"; }
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
}
###
### Профайл
$idd = "profile";
$url = "billing.php?do=profile";
$text = $_lang[BillingMenuProfile];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
###
### Настройки
$idd = "settings";
$url = "billing.php?do=settings";
$text = $_lang[BillingMenuSettings];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
###
### Почта
if (GetSetting('mailLogUserEnable')) {
$idd = "maillogs";
$url = "billing.php?do=maillogs";
$text = $_lang[BillingMenuMail];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
}
###
### Каталог
if (GetSetting("catalog_enable")) {
$idd = "catalog";
$url = "billing.php?do=catalog";
$text = $_lang[BillingMenuCatalog];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
}
###
### Whois
if (@in_array("domains",$weSalesTypes)) {
$idd = "whois";
$url = "whois.php";
$text = $_lang[BillingMenuWhois];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
}
###
$r=GetUsersMenu("","menu");
while ($rr = @mysql_fetch_object($r)) {
$name=array();
$link=array();
$img=array();
if ($rr->active) {
$name = parseRPStrArray($rr->name,":xxx:",":xx:");
$link = parseRPStrArray($rr->link,":xxx:",":xx:");
$img = parseRPStrArray($rr->img,":xxx:",":xx:");
if ($lngUser and $languages[$lngUser] and $name[$lngUser] and $link[$lngUser]) {$link = $link[$lngUser];$name = $name[$lngUser];$img = $img[$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $name[$lngDefault] and $link[$lngDefault]) {$link = $link[$lngDefault];$name = $name[$lngDefault];$img = $img[$lngDefault];} else {$link = $link[russian];$name = $name[russian];$img = $img[russian];}
### Собственные пункты
$url = $link;
$text = $name;
$img = $img;
$class = "menu_link";
if (!@in_array("id".$rr->id,$disallowedMenus)) {
if ($isImgMenu) {$img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
###
}
}
### Выход
$idd = "logout";
$url = "billing.php?do=logout";
$text = $_lang[BillingMenuLogout];
$class = "menu_link";
$usersMenuTextDelimiter = "";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
###
if ($isTextMenu) { $resPrint .= "<BR>"; $usersMenuTextDelimiter = GetSetting('usersMenuTextDelimiter'); }
############################################################
# $cnt=count($weSalesTypes); $j=0;
if ($isTextMenu) { $resPrint .= "<B class='menu_category'>".$_lang[BillingMenuOrder].":</b> "; }
### Заказать хостинг
if (@in_array("hosting",$weSalesTypes)) {
$idd = "orderHosting";
$url = "order.php";
$text = $_lang[OrderType]["hosting"];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
# if ($isTextMenu) {$j++; if ($j < $cnt) {$resPrint .= ", ";}}
}
###
### Заказать реселлинг
if (@in_array("reseller",$weSalesTypes)) {
$idd = "orderReseller";
$url = "order.php?vid=reseller";
$text = $_lang[OrderType]["reseller"];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
# if ($isTextMenu) {$j++; if ($j < $cnt) {$resPrint .= ", ";}}
}
###
### Заказать VDS
if (@in_array("vds",$weSalesTypes)) {
$idd = "orderVds";
$url = "order.php?vid=vds";
$text = $_lang[OrderType]["vds"];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
# if ($isTextMenu) {$j++; if ($j < $cnt) {$resPrint .= ", ";}}
}
###
### Заказать сервер
if (@in_array("dedicated",$weSalesTypes)) {
$idd = "orderDedicated";
$url = "order.php?vid=dedicated";
$text = $_lang[OrderType]["dedicated"];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
# if ($isTextMenu) {$j++; if ($j < $cnt) {$resPrint .= ", ";}}
}
###
### Заказать VPN
if (@in_array("vpn",$weSalesTypes)) {
$idd = "orderVpn";
$url = "order.php?vid=vpn";
$text = $_lang[OrderType]["vpn"];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
# if ($isTextMenu) {$j++; if ($j < $cnt) {$resPrint .= ", ";}}
}
###
### Заказать SSH
if (@in_array("ssh",$weSalesTypes)) {
$idd = "orderSsh";
$url = "order.php?vid=ssh";
$text = $_lang[OrderType]["ssh"];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
# if ($isTextMenu) {$j++; if ($j < $cnt) {$resPrint .= ", ";}}
}
###
### Заказать домен
if (@in_array("domains",$weSalesTypes)) {
$idd = "orderDomains";
$url = "order.php?type=d";
$text = $_lang[Domain];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
# if ($isTextMenu) {$j++; if ($j < $cnt) {$resPrint .= ", ";}}
}
###
### Заказать домены оптом
if (@in_array("domainsopt",$weSalesTypes)) {
$idd = "orderDomainsOpt";
$url = "order.php?type=dopt";
$text = $_lang[DomainOpt];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
# if ($isTextMenu) {$j++; if ($j < $cnt) {$resPrint .= ", ";}}
}
###
### Заказать товар/услугу
if (@in_array("shop",$weSalesTypes)) {
$idd = "orderShop";
$url = "order.php?type=shop";
$text = $_lang[OrderItem];
$class = "menu_link";
if (!@in_array($idd,$disallowedMenus)) {
if ($isImgMenu) {if ($lngUser and $languages[$lngUser] and $usersMenuImgData[texts][$idd][$lngUser]) {$text = $usersMenuImgData[texts][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[texts][$idd][$lngDefault]) {$text = $usersMenuImgData[texts][$idd][$lngDefault];} else {$text = $usersMenuImgData[texts][$idd][russian];}if ($lngUser and $languages[$lngUser] and $usersMenuImgData[imgs][$idd][$lngUser]) {$img = $usersMenuImgData[imgs][$idd][$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $usersMenuImgData[imgs][$idd][$lngDefault]) {$img = $usersMenuImgData[imgs][$idd][$lngDefault];} else {$img = $usersMenuImgData[imgs][$idd][russian];} $img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
# if ($isTextMenu) {$j++; if ($j < $cnt) {$resPrint .= ", ";}}
}
###
$r=GetUsersMenu("","order");
while ($rr = @mysql_fetch_object($r)) {
$name=array();
$link=array();
$img=array();
if ($rr->active) {
$name = parseRPStrArray($rr->name,":xxx:",":xx:");
$link = parseRPStrArray($rr->link,":xxx:",":xx:");
$img = parseRPStrArray($rr->img,":xxx:",":xx:");
if ($lngUser and $languages[$lngUser] and $name[$lngUser] and $link[$lngUser]) {$link = $link[$lngUser];$name = $name[$lngUser];$img = $img[$lngUser];} else if ($lngDefault and $languages[$lngDefault] and $name[$lngDefault] and $link[$lngDefault]) {$link = $link[$lngDefault];$name = $name[$lngDefault];$img = $img[$lngDefault];} else {$link = $link[russian];$name = $name[russian];$img = $img[russian];}
### Собственные пункты
$url = $link;
$text = $name;
$img = $img;
$class = "menu_link";
if (!@in_array("id".$rr->id,$disallowedMenus)) {
if ($isImgMenu) {$img = "<img src=./_rootimages/".$img." title='$text' border=0>"; $valign=""; $align=""; if ($usersMenuImgPosition == "left") { $align = "left"; $leftAddon = "$img ";} else if ($usersMenuImgPosition == "up") { $align = "center"; $leftAddon = "$img<BR>"; $valign="top";} else { $leftAddon = ""; } if ($usersMenuImgPosition == "down") { $align = "center"; $rightAddon = "<BR>$img"; $valign="bottom";} else if ($usersMenuImgPosition == "right") { $align = "right"; $rightAddon = " $img";} else { $rightAddon = ""; } if ($i == 1) { $resPrint .= "<tr><td align='$align' valign='$valign'>";} else { $resPrint .= "<td align='$align' valign='$valign'>"; }} $resPrint .= "<a href=$url class='$class'>".$leftAddon.$text.$rightAddon."</a>".$usersMenuTextDelimiter;if ($isImgMenu) {if ($i == $usersMenuImgRowCount) { $resPrint .= "</td></tr><tr><td colspan=$usersMenuImgRowCount style='height: ".$usersMenuImgStrokiPadding."px'></td></tr>"; $i = 1; } else { $resPrint .= "</td><td style='width: ".$usersMenuImgRowPadding."px'></td>"; $i++; } $leftAddon = ""; $rightAddon = "";}
}
###
}
}
if ($isTextMenu) { $resPrint = preg_replace("/".$usersMenuTextDelimiter."$/ui","",$resPrint); $resPrint .= "<BR>"; }
if ($isImgMenu) { $resPrint .= "</table><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>] <B class='menu_category'>".$_lang[BillingMenuId].":</b> <span class='menu_text'>".$_SESSION[userId]."</span><BR>"; }
$resPrint .= "<BR>";
if ($enc == "utf-8") {
} else if ($enc == "koi8-r") {
$resPrint = iconv("utf-8", "KOI8-R//IGNORE", $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) {
global $admin;
$disallowedMenus = @mb_split("::", $admin->disallowedMenus);
$user = GetUserById($uid);
print "[ <B>$user->login</B> ] : [ ";
if (!@in_array("bills",$disallowedMenus) and checkAdminAccess("billsRead")) { print "<B><A href=?do=bills¶m=uid&search=$uid>счета</a></B> "; }
if (!@in_array("orders",$disallowedMenus) and checkAdminAccess("ordersRead")) { print "- <B><a href=?do=orders¶m=uid&search=$uid>заказы</a></B> "; }
if (!@in_array("domains",$disallowedMenus) and checkAdminAccess("domainsRead")) { print "- <B><a href=?do=domains¶m=uid&search=$uid>домены</a></B> "; }
if (!@in_array("shop",$disallowedMenus) and checkAdminAccess("shopRead")) { print "- <B><a href=?do=shop¶m=uid&search=$uid>товары</a></B> "; }
if (checkAdminAccess("clientSpecialCostRead")) { print "- <B><a href=?do=specialcosts&uid=$uid>спец. цены</a></B> "; }
if (!@in_array("tickets",$disallowedMenus) and checkAdminAccess("ticketsRead")) { print "- <B><a href=?do=tickets&uid=$uid>тикеты</a></B> "; }
if (checkAdminAccess("clientProfileRead")) { print "- <B><a href=?do=profile&id=$uid>профайл</a></B> "; }
if (checkAdminAccess("clientSettingsRead")) { print "- <B><a href=?do=usersettings&id=$uid>настройки</a></B> "; }
if (checkAdminAccess("clientHistoryRead")) { print "- <B><a href=?do=history&uid=$uid>история</a></B> "; }
if ($user->api) { print "- <B><a href=?do=apilogs¶m=login&search=$user->login>логи api</a></B> "; }
if (checkAdminAccess("clientsRead")) { print "- <B><A href=?do=fullinfo&id=$uid>полное инфо</a></b> "; }
print "]<BR><BR>";
}
function printWhoisForm($url = "", $rowsCnt = "", $enc = "windows-1251") {
global $domain, $checkedzones, $zone, $_lang;
if (!$url) { $url = "whois.php"; }
if (!$rowsCnt) { $rowsCnt = 6; }
$result = "<form action='$url' method='post' name='whois'>";
$result .= "<table class='rpTableBlank'><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;
$id = 0;
$haveFavorite = 0;
if ($zone and !$checkedzones) { $checkedzones[$zone] = "$zone"; }
$result .= "<table class='rpTableBlank'>";
while (list($k, $v) = @each($zones)) {
$cnt++;
$id++;
$oneZone = GetZoneByzone($v);
$jsCheckAll .= "document.getElementById('wchk$id').checked=true;";
$jsUnCheckAll .= "document.getElementById('wchk$id').checked=false;";
if ($oneZone->isFavorite) { $haveFavorite = 1; $jsCheckFavorite .= "document.getElementById('wchk$id').checked=true;"; } else { $jsCheckFavorite .= "document.getElementById('wchk$id').checked=false;"; }
if ($cnt == 1) { $result .= "<tr><td>"; }
else { $result .= "<td>"; }
if (($checkedzones and @in_array($v, $checkedzones)) or (!$checkedzones and $oneZone->isFavorite)) { $addon = "checked"; } else { $addon = ""; }
$result .= "<input class=input type=checkbox name=checkedzones[$v] id=wchk$id value='$v' $addon> .$v";
if ($cnt == $rowsCnt) { $cnt=0; $result .= "</td></tr>"; }
else { $result .= "</td>";}
}
$result .= "</table>";
$result .= "</td></tr><tr><td align=center>";
$result .= "[ <a href='#' class=whoisLink onclick="$jsCheckAll return false;">".$_lang[WhoisCheckAll]."</a> ] ";
if ($haveFavorite) { $result .= "[ <a href='#' class=whoisLink onclick="$jsCheckFavorite return false;">".$_lang[WhoisCheckFavorite]."</a> ] ";}
$result .= "[ <a href='#' class=whoisLink onclick="$jsUnCheckAll return false;">".$_lang[WhoisUnCheckAll]."</a> ]<BR><BR>";
}
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//IGNORE", $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>";
mconnect();
$r=@mysql_query("select * from pay_systems where allowPartnerMoneyOut=1 order by sort,id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($rr = mysql_fetch_object($r)) {
if ($rr->type == "webmoney") { $val = $_lang[payWebMoney]; }
else if ($rr->type == "perfectmoney") { $val = $_lang[payPerfectMoney]; }
else if ($rr->type == "superlend") { $val = $_lang[paySuperLend]; }
else if ($rr->type == "yandex") { $val = $_lang[payYandex]; }
else if ($rr->type == "pro") { $val = $_lang[payYandex]; }
else if ($rr->type == "egold") { $val = $_lang[payEgold]; }
else if ($rr->type == "rupay") { $val = $_lang[payRBKMoney]; }
else if ($rr->type == "zpay") { $val = $_lang[payZPayment]; }
else if ($rr->type == "robox") { $val = $_lang[payRoboxchange]; }
else if ($rr->type == "ikass") { $val = $_lang[payInterkassa]; }
else if ($rr->type == "easypay") { $val = $_lang[payEasyPay]; }
else if ($rr->type == "webpay") { $val = $_lang[payWebPay]; }
else if ($rr->type == "portmone") { $val = $_lang[PayPortmone]; }
else if ($rr->type == "privatbank") { $val = $_lang[PayPrivatbank]; }
else if ($rr->type == "p24") { $val = $_lang[PayP24]; }
else if ($rr->type == "liqpay") { $val = $_lang[PayLiqpay]; }
else if ($rr->type == "moneyua") { $val = $_lang[PayMoneyua]; }
else if ($rr->type == "twopay") { $val = $_lang[Pay2pay]; }
else if ($rr->type == "smscoin") { $val = $_lang[PaySMSCoin]; }
else if ($rr->type == "paypal") { $val = $_lang[PayPal]; }
else if ($rr->type == "twoco") { $val = $_lang[Pay2Checkout]; }
else if ($rr->type == "authorize") { $val = $_lang[PayAuthorize]; }
else if ($rr->type == "upc") { $val = $_lang[payUPC]; }
else if ($rr->type == "a1lite") { $val = $_lang[payA1Lite]; }
else if ($rr->type == "taulinkkz") { $val = $_lang[payTaulinkKZ]; }
else if ($rr->type == "qiwikz") { $val = $_lang[payQiwiKZ]; }
else if ($rr->type == "telemoney") { $val = $_lang[payTeleMoney]; }
else if ($rr->type == "intellectmoney") { $val = $_lang[payIntellectMoney]; }
else if ($rr->type == "monexy") { $val = $_lang[payMoneXy]; }
else if ($rr->type == "netcard") { $val = $_lang[payNetCard]; }
else if ($rr->type == "netmoney") { $val = $_lang[payNetMoney]; }
else if ($rr->type == "assist") { $val = $_lang[payAssist]; }
else if ($rr->type == "kkbkz") { $val = $_lang[payKkbkz]; }
else if ($rr->type == "kzmkz") { $val = $_lang[payKzmkz]; }
else if ($rr->type == "copayco") { $val = $_lang[PayCoPAYCo]; }
else if ($rr->type == "qiwi") { $val = $_lang[payQIWI]; }
else if ($rr->type == "sprypay") { $val = $_lang[paySpryPay]; }
else if ($rr->type == "liberty") { $val = $_lang[payLibertyReserve]; }
else if ($rr->type == "onpay") { $val = $_lang[payOnPay]; }
else if ($rr->type == "easysoft") { $val = $_lang[payEasySoft]; }
else if ($rr->type == "payu") { $val = $_lang[PayPayU]; }
else { $val = $rr->name; }
print "<option>$val</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 printAddonsGroupsSelect($id = '') {
print "<select class=input name=addonsgroup><option></option>";
$r = GetAddonsGroups();
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, $dbhost, $dbuser, $dbpass, $dbname;
$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=mt_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 = mb_split("-",$orderShop->todate);
$year = $toDate[0]; $month = $toDate[1]; $day = $toDate[2];
}
$avdesk = new AVDESK();
$avdesk->init($shopItem->field1,$shopItem->field2,decodePwd($shopItem->field3));
$url = $avdesk->createUser($login,$pwd,$shopItem->field4,$year,$month,$day,"yes");
mconnect();
if ($url) {
@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;
}
}
else { $error = "Не указан путь к AV-Desk, логин администратора, пароль администратора или ID группы."; }
}
else if ($shopItem->type == "avdesk6") {
if ($shopItem->field1 and $shopItem->field2 and $shopItem->field3 and $shopItem->field4) {
$pwd=generatePassword();
$login_addon=mt_rand();
$login_addon=substr($login_addon,0,3);
$login = substr($user->login, 0, 5) . $login_addon;
if ($shopItem->costtype == "one") {
$expires = 0;
} else {
$expires = $orderShop->todate;
}
$avdesk = new AVDESK6();
$avdesk->init($shopItem->field1,$shopItem->field2,decodePwd($shopItem->field3));
$res = $avdesk->createStation($login,$pwd,$shopItem->field4,$expires,$login,"RootPanel user $user->login (ID #$user->id), shop order ID #$orderShop->id",$user->email);
$url = $res[url];
mconnect();
if ($res[url]) {
@mysql_query("update orders_shop set field1='$login',field2='$pwd',field3='$res[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;
}
}
else { $error = "Не указан путь к AV-Desk, логин администратора, пароль администратора или ID группы."; }
}
else if ($shopItem->type == "ispmanagerlite" or $shopItem->type == "ispmanagerlitefull" or $shopItem->type == "ispmanagerlitetrial" or $shopItem->type == "ispmanagerpro" or $shopItem->type == "ispmanagerprofull" or $shopItem->type == "ispmanagerprotrial" or $shopItem->type == "vdsmanagerlinux" or $shopItem->type == "vdsmanagerlinuxfull" or $shopItem->type == "vdsmanagerfreebsd" or $shopItem->type == "vdsmanagerfreebsdfull" or $shopItem->type == "billmanagerstandart" or $shopItem->type == "billmanageradvanced" or $shopItem->type == "billmanagercorporate" or $shopItem->type == "dsmanager" or $shopItem->type == "dsmanagerfull" or $shopItem->type == "dnsmanagerfull" or $shopItem->type == "ipmanagerfull") {
if ($shopItem->field2 and $shopItem->field3) {
if ($orderShop->field1 and $orderShop->field2) {
if ($shopItem->field4 == "paylicenseru") {
$paylicenseru = new PAYLICENSERU();
$paylicenseru->init($shopItem->field2,decodePwd($shopItem->field3));
$resultId = $paylicenseru->createLicense($shopItem->type, $orderShop->field1, $orderShop->field2);
mconnect();
if ($resultId) {
@mysql_query("update orders_shop set field3='$resultId',status='1' where id='$orderShop->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $paylicenseru->error;
}
} else {
$billmgr = new BILLMGR();
$billmgr->init($shopItem->field4,$shopItem->field2,decodePwd($shopItem->field3));
$resultId = $billmgr->createLicense($shopItem->type, $shopItem->costtype, $orderShop->field1, $orderShop->field2);
mconnect();
if ($resultId) {
@mysql_query("update orders_shop set field3='$resultId',status='1' where id='$orderShop->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $billmgr->error;
}
}
}
else { $error = "Не указано имя или IP лицензии."; }
}
else { $error = "Не указан логин или пароль от BILLmanager/API."; }
}
else if ($shopItem->type == "soft") {
if (file_exists($full_home_path."/_rootsoft/".$shopItem->field1)) {
if ($shopItem->field4) {
$attachFile = $full_home_path."/_rootsoft/".$shopItem->field1;
}
@mysql_query("update orders_shop set status='1' where id='$orderShop->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
}
else { $error = "Не найден файл ".$full_home_path."/_rootsoft/".$shopItem->field1; }
}
else { $error = "Не известный тип товара $shopItem->type";}
if (!$error and $shopItem->tplsubj and $shopItem->tplmsg) {
$subject=htmlDecode($shopItem->tplsubj); $template=htmlDecode($shopItem->tplmsg);
$mailType = $shopItem->tplIsHtml;
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);
# AV-Desk
if ($shopItem->type == "avdesk" or $shopItem->type == "avdesk6") {
$template = str_replace('{login}',$login,$template);
$template = str_replace('{password}',$pwd,$template);
$template = str_replace('{url}',$url,$template);
}
# ISP
$template = str_replace('{license}',$orderShop->field1,$template);
$template = str_replace('{ip}',$orderShop->field2,$template);
# Soft
if ($shopItem->type == "soft") {
$template = str_replace('{url}',$full_www_path."billing.php?do=download&type=shop&id=$orderShop->id",$template);
$template = str_replace('{days}',$shopItem->field2,$template);
}
WriteMailLog($subject,$template,$user->id);
sendmail($user->email,$company_name,$manager_email,$subject,$template,$attachFile,'',$mailType);
sendmail($user->email2,$company_name,$manager_email,$subject,$template,$attachFile,'',$mailType);
$subject = "Duplicate: ".$subject;
$admEmails=GetAdminEmailsWhereTrueParam("sendcreateactmsg");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em, '', $manager_email, $subject, $template,$attachFile,'',$mailType);
}
}
}
}
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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function renewShopOrder($orderid, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $full_www_path, $dbhost, $dbuser, $dbpass, $dbname;
$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 = mb_split("-",$orderShop->todate);
$year = $toDate[0]; $month = $toDate[1]; $day = $toDate[2];
}
$avdesk = new AVDESK();
$avdesk->init($shopItem->field1,$shopItem->field2,decodePwd($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 if ($shopItem->type == "avdesk6") {
if ($orderShop->field1) {
if ($shopItem->field1 and $shopItem->field2 and $shopItem->field3 and $shopItem->field4) {
if ($shopItem->costtype == "one") {
$expires = 0;
} else {
$expires = $orderShop->todate;
}
$avdesk = new AVDESK6();
$avdesk->init($shopItem->field1,$shopItem->field2,decodePwd($shopItem->field3));
$result = $avdesk->renewStation($orderShop->field1,$expires);
if (!$result) {
$error = $avdesk->error;
}
mconnect();
}
else { $error = "Не указан путь к AV-Desk, логин администратора, пароль администратора или ID группы."; }
}
else { $error = "Не указан логин клиента на сервере для заказа ID # $orderShop->id, $shopItem->name."; }
}
else if ($shopItem->type == "ispmanagerlite" or $shopItem->type == "ispmanagerlitefull" or $shopItem->type == "ispmanagerlitetrial" or $shopItem->type == "ispmanagerpro" or $shopItem->type == "ispmanagerprofull" or $shopItem->type == "ispmanagerprotrial" or $shopItem->type == "vdsmanagerlinux" or $shopItem->type == "vdsmanagerlinuxfull" or $shopItem->type == "vdsmanagerfreebsd" or $shopItem->type == "vdsmanagerfreebsdfull" or $shopItem->type == "billmanagerstandart" or $shopItem->type == "billmanageradvanced" or $shopItem->type == "billmanagercorporate" or $shopItem->type == "dsmanager" or $shopItem->type == "dsmanagerfull" or $shopItem->type == "dnsmanagerfull" or $shopItem->type == "ipmanagerfull") {
if ($orderShop->field3) {
if ($shopItem->field2 and $shopItem->field3) {
if ($shopItem->field4 == "paylicenseru") {
$paylicenseru = new PAYLICENSERU();
$paylicenseru->init($shopItem->field2,decodePwd($shopItem->field3));
$result = $paylicenseru->renewLicense($orderShop->field3);
if (!$result) {
$error = $paylicenseru->error;
}
} else {
$billmgr = new BILLMGR();
$billmgr->init($shopItem->field4,$shopItem->field2,decodePwd($shopItem->field3));
$result = $billmgr->renewLicense($shopItem->type, $shopItem->costtype, $orderShop->field3);
if (!$result) {
$error = $billmgr->error;
}
}
mconnect();
}
else { $error = "Не указан логин или пароль от BILLmanager/API."; }
}
else { $error = "Не указан ID лицензии для заказа 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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function updateShopOrder($orderid, $field, $value, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $full_www_path, $dbhost, $dbuser, $dbpass, $dbname;
$orderShop = GetOrderShopById($orderid);
$shopItem = GetShopItemById($orderShop->item);
$user = GetUserById($orderShop->uid);
if ($orderShop->id) {
if ($shopItem->id) {
if ($user->id) {
if ($shopItem->type == "ispmanagerlite" or $shopItem->type == "ispmanagerlitefull" or $shopItem->type == "ispmanagerlitetrial" or $shopItem->type == "ispmanagerpro" or $shopItem->type == "ispmanagerprofull" or $shopItem->type == "ispmanagerprotrial" or $shopItem->type == "vdsmanagerlinux" or $shopItem->type == "vdsmanagerlinuxfull" or $shopItem->type == "vdsmanagerfreebsd" or $shopItem->type == "vdsmanagerfreebsdfull" or $shopItem->type == "billmanagerstandart" or $shopItem->type == "billmanageradvanced" or $shopItem->type == "billmanagercorporate" or $shopItem->type == "dsmanager" or $shopItem->type == "dsmanagerfull" or $shopItem->type == "dnsmanagerfull" or $shopItem->type == "ipmanagerfull") {
if ($orderShop->field3) {
if ($field == "name" or $field == "ip") {
if ($value) {
if ($shopItem->field2 and $shopItem->field3) {
if ($shopItem->field4 == "paylicenseru") {
$paylicenseru = new PAYLICENSERU();
$paylicenseru->init($shopItem->field2,decodePwd($shopItem->field3));
$result = $paylicenseru->updateLicense($orderShop->field3, $field, $value);
if (!$result) {
$error = $paylicenseru->error;
}
} else {
$billmgr = new BILLMGR();
$billmgr->init($shopItem->field4,$shopItem->field2,decodePwd($shopItem->field3));
$result = $billmgr->updateLicense($orderShop->field3, $field, $value);
if (!$result) {
$error = $billmgr->error;
}
}
mconnect();
}
else { $error = "Не указан логин или пароль от BILLmanager."; }
}
else { $error = "Не указано значение поля для изменения данных для заказа ID # $orderShop->id, $shopItem->name."; }
}
else { $error = "Не указан тип поля для изменения данных для заказа ID # $orderShop->id, $shopItem->name."; }
}
else { $error = "Не указан ID лицензии для заказа ID # $orderShop->id, $shopItem->name."; }
}
else { $error = "Не известный тип товара $shopItem->type";}
}
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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function deleteShopOrder($orderid, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $full_www_path, $dbhost, $dbuser, $dbpass, $dbname;
$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,decodePwd($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 if ($shopItem->type == "avdesk6") {
if ($orderShop->field1) {
if ($shopItem->field1 and $shopItem->field2 and $shopItem->field3 and $shopItem->field4) {
$avdesk = new AVDESK6();
$avdesk->init($shopItem->field1,$shopItem->field2,decodePwd($shopItem->field3));
$result = $avdesk->deleteStation($orderShop->field1);
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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function updateCourses($sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $full_www_path, $dbhost, $dbuser, $dbpass, $dbname;
$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, 4);
$sale1 = $result[$maincurrency][sale];
$sale2 = $result[$code][sale];
$kurs[sale] = round($sale1/$sale2, 4);
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, 4);
@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, 4);
@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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function createUser($orderid, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $full_www_path, $dbhost, $dbuser, $dbpass, $dbname, $HYPERVM_DEFAULT_OS, $SOLUSVM_DEFAULT_OS;
$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->accLimit > 0 and GetServerUserCount($server->id) >= $server->accLimit)) {
if (($server->type and ($server->ip or $server->type == "gproxy" or $server->type == "gamecp") and ($server->user or $server->type == "gproxy" or $server->type == "gamecp") and ($server->password or $server->cpanelHash) and ($server->userip or $server->type == "hypervm" or $server->type == "hypervmxen" or $server->type == "vdsmanager" or $server->type == "gproxy" or $server->type == "gamecp" or $server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm")) or ($server->type == "ventrilo" or $server->type == "ventrilols" or $server->type == "teamspeak2" or $server->type == "teamspeak3")) {
if (!$tarif->onlyDedicatedIP or ($tarif->onlyDedicatedIP and GetFreeServerIP($server->id))) {
$user = GetUserById($order->uid);
if ($user->id) {
$profile = GetUserProfileByUserId($user->id);
if ($tarif->onlyDedicatedIP) {
$userip=GetFreeServerIP($server->id);
if ($userip->id) {
$useripid=$userip->id;
$userip=$userip->ip;
} else {
$error = "В биллинге отсутствуют свободные выделенные IP.";
}
} else {
$userip=$server->userip;
}
if (!$error) {
if ($order->serverpassword) {
$pwd = decodePwd($order->serverpassword);
} else {
$pwd = generatePassword();
}
if ($order->serverlogin) {
$login = $order->serverlogin;
}
else {
$user->login = mb_strtolower($user->login);
$login_addon=mt_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,decodePwd($server->password),$server->ventrilo_resid);
$result = $ventrilo->createAccount($tarifServerName, $server->ventrilo_placeid, $order->id, $login, $pwd);
mconnect();
if ($result) {
$remarkUser = "IP/Port: ".$result[ip].":".$result[port]."nURL: ".$server->ventrilo_url;
@mysql_query("update orders set serverlogin='$user->email',serverpassword='".encodePwd($pwd)."',serverid='$server->id',ventriloId='$result[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 == "teamspeak2") {
$teamspeak = new TeamSpeak2($server->user,decodePwd($server->password));
if ($profile->name) { $clientFirst = GotoTranslit($profile->name); } else { $clientFirst = "None"; }
if ($profile->surname) { $clientLast = GotoTranslit($profile->surname); } else { $clientLast = "None"; }
$result = $teamspeak->createAccount($clientFirst, $clientLast, $user->email, $server->ventrilo_placeid, $tarifServerName, $login, $pwd, $order->id);
mconnect();
if ($result) {
$remarkUser = "IP/Port: ".$result."nURL: ".$server->ventrilo_url;
@mysql_query("update orders set serverlogin='$login',serverpassword='".encodePwd($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 = $teamspeak->error;
}
}
else if ($server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm") {
$solusvm = new SolusVM();
$solusvm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$panelClientLogin = $user->panelClientLogin;
$panelClientPassword = decodePwd($user->panelClientPassword);
if (!$panelClientLogin) {
$panelClientLogin = $login;
$panelClientPassword = $pwd;
if ($profile->name) { $clientFirst = GotoTranslit($profile->name); } else { $clientFirst = "None"; }
if ($profile->surname) { $clientLast = GotoTranslit($profile->surname); } else { $clientLast = "None"; }
$clientCompany = "RootPanel user #".$user->id.", ".$user->login;
$panelClientLogin = $solusvm->createClient($panelClientLogin, $panelClientPassword, $profile->email, $clientFirst, $clientLast, $clientCompany);
mconnect();
if ($panelClientLogin) {
@mysql_query("update users set panelClientLogin='$panelClientLogin',panelClientPassword='".encodePwd($panelClientPassword)."' where id='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
} else {
$login = $panelClientLogin;
$pwd = $panelClientPassword;
}
if ($panelClientLogin) {
if (!$panelClientPassword) { $panelClientPassword = $pwd; }
if ($server->type == "solusvmopenvz") { $solusType = "openvz"; } else if ($server->type == "solusvmxen") { $solusType = "xen"; } else if ($server->type == "solusvmxenhvm") { $solusType = "xen hvm"; } else if ($server->type == "solusvmkvm") { $solusType = "kvm"; }
if ($server->node) { $node = $server->node; } else { $node = "localhost"; }
if ($order->servername) { $hostname = $order->servername; } else if ($order->domain) { $hostname = $order->domain; } else { $hostname = $login.".vm"; }
$ips = 1;
$addons = GetAddonsIdsByTxt($order->addons);
if ($addons) {
while (list($k,$v) = each($addons)) {
$addon = GetAddonById($v);
if ($addon->isOs) {
$os = $addon->textid;
}
if (preg_match("/solusvmextraip/ui",$addon->textid)) {
$ips = $ips + 1;
}
}
}
if (!$os) { $os = $SOLUSVM_DEFAULT_OS; }
$result = $solusvm->createServer($solusType,$node,$hostname,$panelClientPassword,$panelClientLogin,$tarifServerName,$os,$ips,$server->nodegroup);
mconnect();
if ($result) {
@mysql_query("update orders set serverlogin='$panelClientLogin',serverpassword='".encodePwd($panelClientPassword)."',serverid='$server->id',ventriloId='$result[vserverid]',status='$status'$sqlAddDays where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$userip = $result[mainipaddress];
if ($result[extraipaddress]) { $userextraips = $result[extraipaddress]; $userextraips = @mb_split(",",$userextraips);}
$useripid = @mysql_query("select id from servers_ips where server_id='$server->id' and ip='$userip'");
$useripid = @mysql_fetch_object($useripid);
$useripid = $useripid->id;
############### ISPManager Lite Trial License Create Begin #########
if ($userip and preg_match("/ispmanager/ui",$os)) {
$shopItem = @mysql_query("select * from shop_items where (type='ispmanagerlite' or type='ispmanagerlitefull') and active='1' LIMIT 0,1");
$shopItem = @mysql_fetch_object($shopItem);
if ($shopItem->id) {
if ($shopItem->field4 == "paylicenseru") {
$paylicenseru = new PAYLICENSERU();
$paylicenseru->init($shopItem->field2,decodePwd($shopItem->field3));
$paylicenseru->createLicense("ispmanagerlitetrial", $userip, $userip);
$ispManagerLiteTrialLicenseError = $paylicenseru->error;
} else {
$billmgr = new BILLMGR();
$billmgr->init($shopItem->field4,$shopItem->field2,decodePwd($shopItem->field3));
$billmgr->createLicense("ispmanagerlitetrial", "one", $userip, $userip);
$ispManagerLiteTrialLicenseError = $billmgr->error;
}
if ($ispManagerLiteTrialLicenseError) {
$subject = "Ошибка создания лицензии для VDS";
$template = "Не удалось создать лицензию ISPManager Lite Trial для IP $userip для заказа ID # $order->id.nnОшибка: $ispManagerLiteTrialLicenseError. Сделайте это вручную.";
$manager_email = GetSetting("manager_email");
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em, '', $manager_email, $subject, $template);
}
}
}
}
############### ISPManager Lite Trial License Create End #########
$error = "";
} else {
$error = $solusvm->error;
}
} else {
$error = $solusvm->error;
}
}
else if ($server->type == "hypervm" or $server->type == "hypervmxen") {
$hypervm = new HyperVM();
$hypervm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$addons = GetAddonsIdsByTxt($order->addons);
if ($addons) {
while (list($k,$v) = each($addons)) {
$addon = GetAddonById($v);
if ($addon->isOs) {
$os = $addon->textid;
break;
}
}
}
if ($useripid) { $hypervmip = $userip; $ipnum = 1; } else { $hypervmip = ""; $ipnum = 1; }
if (!$os) { $os = $HYPERVM_DEFAULT_OS; }
if ($server->type == "hypervm") {$servertype = "openvz";} else if ($server->type == "hypervmxen") {$servertype = "xen";}
$result = $hypervm->createServer($login,$pwd,$order->domain,$tarifServerName,$os,$user->email,$ipnum,$hypervmip,$server->name,$servertype);
mconnect();
if ($result) {
$login = $login.".vm";
@mysql_query("update orders set serverlogin='$login',serverpassword='".encodePwd($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 = "";
} else {
$error = $hypervm->error;
}
}
else if ($server->type == "gproxy") {
$gproxy = new GPROXY();
$gproxy->init(decodePwd($server->password));
$use_xml = 0;
$addons = GetAddonsIdsByTxt($order->addons);
if ($addons) {
while (list($k,$v) = each($addons)) {
$addon = GetAddonById($v);
if ($addon->textid == "gproxyyandex") {
$use_xml = 1;
break;
}
}
}
$result = $gproxy->createProxy($use_xml,$tarifServerName,$login,$pwd);
mconnect();
if ($result) {
$remarkUser = $gproxy->getProxyList($result);
if ($remarkUser[status] == "SUCCESS") {
$remarkUser = $remarkUser[response];
$order->remarkUser = $remarkUser;
}
@mysql_query("update orders set serverlogin='$login',serverpassword='".encodePwd($pwd)."',serverid='$server->id',remarkUser='$order->remarkUser',panelUserId='$result',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 = $gproxy->error;
}
}
else if ($server->type == "gamecp") {
$gamecp = new GameCP();
$gamecp->init($server->ventrilo_url,decodePwd($server->password));
if ($order->slots) { $slots = $order->slots; } else { $slots = $tarif->serverslots; }
$result = $gamecp->createClient($login,$pwd,$user->email,$tarifServerName,$slots);
mconnect();
if ($result) {
@mysql_query("update orders set serverlogin='$login',serverpassword='".encodePwd($pwd)."',serverid='$server->id',panelUserId='$result[uid]',ventriloId='$result[gid]',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 = $gamecp->error;
}
}
else if ($server->type == "vdsmanager") {
$vdsmanager = new VDSManager;
$vdsmanager->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
if ($order->domain) { $vdsServerName = $order->domain; } else { $vdsServerName = $login.".vds"; }
if ($useripid) { $vdsIp = $userip; } else { $vdsIp = "auto"; }
$addons = GetAddonsIdsByTxt($order->addons);
if ($addons) {
while (list($k,$v) = each($addons)) {
$addon = GetAddonById($v);
if ($addon->isOs) {
$os = $addon->textid;
}
if ($addon->isPanel) {
$ispLicense = $addon->textid;
}
if ($addon->textid == "vdsm_extns") { $extns = "dnsprovider"; }
if ($addon->textid == "vdsm_backupd") { $backup = "bday"; }
if ($addon->textid == "vdsm_backupw") { $backup = "bweek"; }
if ($addon->textid == "vdsm_backupm") { $backup = "bmonth"; }
}
}
if ($ispLicense != "Lite" and $ispLicense != "Prof") { $ispLicense = "None"; }
if (!$extns) { $extns = "dnsnone"; }
if (!$backup) { $backup = "bnone"; }
$result=$vdsmanager->createVDS($vdsServerName, $vdsIp, $pwd, $tarifServerName, $os, $ispLicense, $extns, $backup, $server->owner);
mconnect();
if ($result) {
$login = $result;
@mysql_query("update orders set serverlogin='$login',serverpassword='".encodePwd($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 = "";
}
else {
$error = $vdsmanager->error;
}
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,decodePwd($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();
@mysql_query("update orders set serverlogin='$login',serverpassword='".encodePwd($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,decodePwd($server->password),$server->cpanelHash);
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();
@mysql_query("update orders set serverlogin='$login',serverpassword='".encodePwd($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 == "rootpanel") {
$rootpanel = new ROOTPANELAPIH;
$rootpanel->init($server->ventrilo_url,$server->user,decodePwd($server->password));
$period = @mysql_query("select * from bills where host_id='$order->id' and renew='0' and newtarif='0' and newserver='0' and newslots='0' and newaddons='' order by id desc LIMIT 0,1") or die(mysql_error());
if (mysql_num_rows($period) > 0) {
$period = @mysql_fetch_object($period);
$period = $period->host_srok;
} else {
$period = 1;
}
$result = $rootpanel->createOrder($tarif->vid, $tarifServerName, $period, $order->domain, "");
mconnect();
if ($result[orderid]) {
$login = $result[serverlogin]; $pwd = $result[serverpassword];
@mysql_query("update orders set serverlogin='$login',serverpassword='".encodePwd($pwd)."',serverid='$server->id',panelUserId='$result[orderid]',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 = $rootpanel->error;
}
}
else if ($server->type == "plesk") {
$plesk = new Plesk;
$plesk->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if ($server->setrulanguage) { $pleskLang = "ru-RU"; } else { $pleskLang = "en-US"; }
if ($profile->name or $profile->surname or $profile->otchestvo) { $pleskName = $profile->surname." ".$profile->name." ".$profile->otchestvo." ($order->id)"; } else { $pleskName = $login." ($order->id)"; }
if ($tarif->vid == "hosting") {
$panelUserId = $order->panelUserId;
if (!$panelUserId) {
$result=$plesk->createUser($login, $pwd, $tarifServerName, $profile->firma, $pleskName, $profile->phone, $profile->fax, $user->email, $profile->street, $profile->city, $profile->oblast, $profile->post, $profile->country, $pleskLang);
if ($result) {
$panelUserId = $result;
mconnect();
@mysql_query("update orders set panelUserId='$panelUserId',serverlogin='$login',serverpassword='".encodePwd($pwd)."' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
}
if ($panelUserId) {
$result=$plesk->createDomain($panelUserId, $order->domain, $userip, $login, $pwd);
}
} else if ($tarif->vid == "reseller") {
$result = false;
$plesk->error = "No support for reseller accounts creating.";
}
if ($result) {
mconnect();
$panelDomainId = $result;
@mysql_query("update orders set panelDomainId='$panelDomainId',serverlogin='$login',serverpassword='".encodePwd($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 ($order->testPeriod and $tarif->testPeriodDomain) { $parkResult = $plesk->createAlias($panelDomainId, $testdomain); }
}
else {
$error = $plesk->error;
}
mconnect();
}
else if ($server->type == "plesk10") {
$plesk = new Plesk10;
$plesk->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if ($server->setrulanguage) { $pleskLang = "ru-RU"; } else { $pleskLang = "en-US"; }
if ($profile->name or $profile->surname or $profile->otchestvo) { $pleskName = $profile->surname." ".$profile->name." ".$profile->otchestvo." ($order->id)"; } else { $pleskName = $login." ($order->id)"; }
if ($tarif->vid == "hosting") {
$panelUserId = $order->panelUserId;
if (!$panelUserId) {
$result=$plesk->createCustomer($login, $pwd, $profile->firma, $pleskName, $profile->phone, $profile->fax, $user->email, $profile->street, $profile->city, $profile->oblast, $profile->post, $profile->country, $pleskLang);
if ($result) {
$panelUserId = $result;
mconnect();
@mysql_query("update orders set panelUserId='$panelUserId',serverlogin='$login',serverpassword='".encodePwd($pwd)."' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
}
if ($panelUserId) {
$result=$plesk->createSubscription($panelUserId, $order->domain, $userip, $login, $pwd, $tarifServerName);
}
} else if ($tarif->vid == "reseller") {
$result=$plesk->createReseller($login, $pwd, $profile->firma, $pleskName, $profile->phone, $profile->fax, $user->email, $profile->street, $profile->city, $profile->oblast, $profile->post, $profile->country, $pleskLang, $tarifServerName);
if ($result) {
$panelUserId = $result;
mconnect();
@mysql_query("update orders set panelUserId='$panelUserId',serverlogin='$login',serverpassword='".encodePwd($pwd)."' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
}
if ($result) {
mconnect();
if ($tarif->vid == "hosting") {
$panelSubcriptionId = $result;
} else {
$panelSubcriptionId = 0;
}
@mysql_query("update orders set panelDomainId='$panelSubcriptionId',serverlogin='$login',serverpassword='".encodePwd($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 ($order->testPeriod and $tarif->testPeriodDomain and $tarif->vid == "hosting") { $parkResult = $plesk->createAlias($panelSubcriptionId, $testdomain); }
}
else {
$error = $plesk->error;
}
mconnect();
}
else if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
if ($tarif->vid == "hosting") {
$result=$autoisp->createAccount($order->domain,$login,$pwd,$tarifServerName,$userip,$user->email,$server->owner);
} else if ($tarif->vid == "reseller") {
if ($useripid) { $ispIP = $userip; } else { $ispIP = "noassign"; }
$result=$autoisp->createResellerAccount($login,$pwd,$tarifServerName,$userip,$user->email,$ispIP);
}
if ($result and $useripid) {
$autoisp->assignIP($login,$userip);
}
if ($result) {
mconnect();
@mysql_query("update orders set serverlogin='$login',serverpassword='".encodePwd($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->error; }
else {
$parkResult = $autoisp->addAlias($order->domain,$testdomain);
if (!$parkResult) { $parkError = $autoisp->error; }
}
}
if ($tarif->addMutualIps and $server->mutualIps) {
$server->mutualIps = @mb_split(",",$server->mutualIps);
if (count($server->mutualIps) > 0) {
while (list($mm,$nn) = @each($server->mutualIps)) {
$nn=trim($nn);
$addMutualResult = $autoisp->addMutualIp($login,$nn);
if (!$addMutualResult) { $addMutualError = "$nn: ".$autoisp->error; break; }
}
}
}
$error = "";
}
else {
$error = $autoisp->error;
}
mconnect();
}
else if ($server->type == "shellscript") {
$command = $tarif->scriptCreate;
$reply = $tarif->scriptCreateReply;
if ($command) {
$addons = GetAddonsIdsByTxt($order->addons);
while (list($kk,$vv) = @each($addons)) {
$oneAddon = GetAddonById($vv);
if ($oneAddon->id) {
$addons[$kk] = $oneAddon->textid;
} else {
$addons[$kk] = "";
}
}
if ($addons) {$addons = @join(":x:",$addons);} else {$addons = "";}
$command = preg_replace("/{login}/ui","$login",$command);
$command = preg_replace("/{userlogin}/ui","$user->login",$command);
$command = preg_replace("/{password}/ui","$pwd",$command);
$command = preg_replace("/{orderid}/ui","$order->id",$command);
$command = preg_replace("/{domain}/ui","$order->domain",$command);
$command = preg_replace("/{serverip}/ui","$server->ip",$command);
$command = preg_replace("/{userip}/ui","$userip",$command);
$command = preg_replace("/{addons}/ui","$addons",$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='".encodePwd($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 $userip) {
@mysql_query("update orders set ipaddr='$userip' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
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 (!$error and @count($userextraips) > 0) {
while (list($ipi,$ipv) = @each($userextraips)) {
@mysql_query("update servers_ips set order_id='$order->id',isMain='0' where server_id='$server->id' and ip='$ipv'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
}
if (!$error and $order->testPeriod and $tarif->testPeriodDomain and !$parkResult) {
if ($parkError) {$parkError = " (".$parkError.")"; }
$subject = "Ошибка парковки домена";
$template = "Не удалось припарковать домен $testdomain к домену $order->domain на сервере $server->name для заказа ID # $order->id в рамках тестового периода$parkError. Сделайте это вручную.";
$manager_email = GetSetting("manager_email");
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em, '', $manager_email, $subject, $template);
}
}
if ($addMutualError) {
$subject = "Ошибка добавления совместного IP";
$template = "Не удалось добавить совместный IP для $login на сервере $server->name для заказа ID # $order->id ($addMutualError). Сделайте это вручную.";
$manager_email = GetSetting("manager_email");
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em, '', $manager_email, $subject, $template);
}
}
if (!$error and $server->sendmsg) {
if ($server->type == "ventrilols") { $server->type = "ventrilo"; }
if ($server->type == "hypervmxen") { $server->type = "hypervm"; }
if ($server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm") { $server->type = "solusvmopenvz"; }
if ($server->type == "rootpanel") { $server->type = "shellscript"; }
$tpl=GetTpl('msg_'.$server->type, $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($server->template) { $template = htmlDecode($server->template); }
if ($subject and $template) {
$company_name=GetSetting('company_name');
$company_url=GetSetting('company_url');
$billing_url=GetSetting('billing_url');
$support_url=GetSetting('support_url');
$manager_email=GetSetting('manager_email');
$subject = str_replace('{domain}',$order->domain,$subject);
if ($server->type == 'ventrilo' || $server->type == 'teamspeak2') {
preg_match('!IP/Port: (.*?:[0-9]{1,10})!si', $order->remarkUser, $temp_result);
$template = str_replace('{ip_port}', $temp_result[1], $template);
}
if ($server->type == 'teamspeak2') {
preg_match('!Token: (.*?)$!si', $order->remarkUser, $temp_result);
$template = str_replace('{token}', $temp_result[1], $template);
}
$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('{billing_url}',$billing_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); }
$template = str_replace('{servername}',$server->name,$template);
$template = str_replace('{serverip}',$server->ip,$template);
$template = str_replace('{remark}', $order->remarkUser, $template);
WriteMailLog($subject,$template,$user->id);
sendmail($user->email,$company_name,$manager_email,$subject,$template,'','',$tpl[type]);
sendmail($user->email2,$company_name,$manager_email,$subject,$template,'','',$tpl[type]);
$subject = "Duplicate: ".$subject;
$admEmails=GetAdminEmailsWhereTrueParam("sendcreateactmsg");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em, '', $manager_email, $subject, $template,'','',$tpl[type]);
}
}
}
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 = "Достигнуто ограничение на количество аккаунтов ($server->accLimit) для сервера ID # $server->id, $server->name."; }
} 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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function renewUser($orderid, $period, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $full_www_path, $dbhost, $dbuser, $dbpass, $dbname;
$order = GetOrderById($orderid);
if ($order->id) {
$tarif = GetTarifById($order->tarif);
if ($tarif->id) {
if ($tarif->serverid) {
$server = GetServers($order->serverid);
if ($server->id) {
if ($server->type == "rootpanel") {
$rootpanel = new ROOTPANELAPIH;
$rootpanel->init($server->ventrilo_url,$server->user,decodePwd($server->password));
$result = $rootpanel->renewOrder($order->panelUserId, $period);
mconnect();
if ($result) {
$error = "";
}
else {
$error = $rootpanel->error;
}
}
else { $error == "Операция не поддерживается для серверов с типом $server->type."; }
} 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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function deleteUser($orderid, $sendErrorEmail = 1) {
global $GLOBALerror, $dbhost, $dbuser, $dbpass, $dbname;
$order = GetOrderById($orderid);
if ($order->id) {
$user=GetUserById($order->uid);
if ($order->serverlogin and $order->serverid) {
$tarif = GetTarifById($order->tarif);
if ($tarif->id) {
if (($tarif->autodelete and !$order->testPeriod) or ($tarif->autodeletetest and $order->testPeriod)) {
$server = GetServers($order->serverid);
if ($server->id) {
if (($server->type and ($server->ip or $server->type == "gproxy" or $server->type == "gamecp") and ($server->user or $server->type == "gproxy" or $server->type == "gamecp") and ($server->password or $server->cpanelHash) and ($server->userip or $server->type == "hypervm" or $server->type == "hypervmxen" or $server->type == "vdsmanager" or $server->type == "gproxy" or $server->type == "gamecp" or $server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm")) or ($server->type == "ventrilo" or $server->type == "ventrilols" or $server->type == "teamspeak2" or $server->type == "teamspeak3")) {
if ($server->type == "ventrilo") {
$ventrilo = new Ventrilo($server->user,decodePwd($server->password),$server->ventrilo_resid);
$result = $ventrilo->terminateAccount($order->id);
if ($result) {
$error = "";
} else {
$error = $ventrilo->error;
}
mconnect();
}
else if ($server->type == "teamspeak2") {
$teamspeak = new TeamSpeak2($server->user,decodePwd($server->password));
$result = $teamspeak->terminateAccount($order->serverlogin);
if ($result) {
$error = "";
} else {
$error = $teamspeak->error;
}
mconnect();
}
else if ($server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm") {
$solusvm = new SolusVM();
$solusvm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$result = $solusvm->terminateServer($order->ventriloId);
if ($result) {
$error = "";
} else {
$error = $solusvm->error;
}
mconnect();
}
else if ($server->type == "hypervm" or $server->type == "hypervmxen") {
$hypervm = new HyperVM();
$hypervm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$result = $hypervm->deleteServer($order->serverlogin);
if ($result) {
$error = "";
} else {
$error = $hypervm->error;
}
mconnect();
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,decodePwd($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,decodePwd($server->password),$server->cpanelHash);
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 == "plesk") {
$plesk = new Plesk;
$plesk->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$result=$plesk->deleteUser($order->panelUserId);
if ($result) {
$error = '';
} else {
$error = $plesk->error;
}
mconnect();
}
else if ($server->type == "plesk10") {
$plesk = new Plesk10;
$plesk->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if ($tarif->vid == "hosting") {
$result=$plesk->deleteCustomer($order->panelUserId);
} else if ($tarif->vid == "reseller") {
$result=$plesk->deleteReseller($order->panelUserId);
}
if ($result) {
$error = '';
} else {
$error = $plesk->error;
}
mconnect();
}
else if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,decodePwd($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 = $autoisp->error;
}
mconnect();
}
else if ($server->type == "vdsmanager") {
$vdsmanager = new VDSManager;
$vdsmanager->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
$result=$vdsmanager->terminateVDS($order->serverlogin);
if ($result) {
$error = '';
} else {
$error = $vdsmanager->error;
}
mconnect();
}
else if ($server->type == "gproxy") {
$gproxy = new GPROXY;
$gproxy->init(decodePwd($server->password));
$result = $gproxy->deleteProxy($order->panelUserId);
if ($result) {
$error = '';
} else {
$error = $gproxy->error;
}
mconnect();
}
else if ($server->type == "gamecp") {
$gamecp = new GameCP;
$gamecp->init($server->ventrilo_url,decodePwd($server->password));
$result = $gamecp->deleteClient($order->panelUserId,$order->ventriloId);
if ($result) {
$error = '';
} else {
$error = $gamecp->error;
}
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("/{userlogin}/ui","$user->login",$command);
$command = preg_replace("/{password}/ui",decodePwd($order->serverpassword),$command);
$command = preg_replace("/{domain}/ui","$order->domain",$command);
$command = preg_replace("/{orderid}/ui","$order->id",$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 = "Операция не поддерживается для серверов с типом $server->type."; }
if (!$error) {
@mysql_query("update servers_ips set order_id='0',isMain='0' where order_id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
} 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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function suspendUser($orderid, $suspend = 1, $sendErrorEmail = 1) {
global $GLOBALerror, $dbhost, $dbuser, $dbpass, $dbname;
$order = GetOrderById($orderid);
if ($order->id) {
$user=GetUserById($order->uid);
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 or $server->type == "gproxy" or $server->type == "gamecp") and ($server->user or $server->type == "gproxy" or $server->type == "gamecp") and ($server->password or $server->cpanelHash) and ($server->userip or $server->type == "hypervm" or $server->type == "hypervmxen" or $server->type == "vdsmanager" or $server->type == "gproxy" or $server->type == "gamecp" or $server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm")) or ($server->type == "ventrilo" or $server->type == "ventrilols" or $server->type == "teamspeak2" or $server->type == "teamspeak3")) {
if ($server->type == "ventrilo") {
$ventrilo = new Ventrilo($server->user,decodePwd($server->password),$server->ventrilo_resid);
if (!$suspend) {
$result = $ventrilo->unSuspendAccount($tarif->servername,$order->id,$order->ventriloId);
}
else if ($suspend) {
$result = $ventrilo->suspendAccount($order->id,$order->ventriloId);
}
if ($result) {
$error = "";
} else {
$error = $ventrilo->error;
}
mconnect();
}
else if ($server->type == "teamspeak2") {
$teamspeak = new TeamSpeak2($server->user,decodePwd($server->password));
if (!$suspend) {
$result = $teamspeak->unSuspendAccount($order->serverlogin,$tarif->servername);
}
else if ($suspend) {
$result = $teamspeak->suspendAccount($order->serverlogin);
}
if ($result) {
$error = "";
} else {
$error = $teamspeak->error;
}
mconnect();
}
else if ($server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm") {
$solusvm = new SolusVM();
$solusvm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if (!$suspend) {
$result = $solusvm->unSuspendServer($order->ventriloId);
}
else if ($suspend) {
$result = $solusvm->suspendServer($order->ventriloId);
}
if ($result) {
$error = "";
} else {
$error = $solusvm->error;
}
mconnect();
}
else if ($server->type == "hypervm" or $server->type == "hypervmxen") {
$hypervm = new HyperVM();
$hypervm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if (!$suspend) {
$result = $hypervm->enableServer($order->serverlogin);
}
else if ($suspend) {
$result = $hypervm->disableServer($order->serverlogin);
}
if ($result) {
$error = "";
} else {
$error = $hypervm->error;
}
mconnect();
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,decodePwd($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,decodePwd($server->password),$server->cpanelHash);
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 == "plesk") {
$plesk = new Plesk;
$plesk->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if (!$suspend) {
$result=$plesk->unsuspendUser($order->panelUserId);
}
else if ($suspend) {
$result=$plesk->suspendUser($order->panelUserId);
}
if ($result) {
$error = '';
} else {
$error = $plesk->error;
}
mconnect();
}
else if ($server->type == "plesk10") {
$plesk = new Plesk10;
$plesk->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if (!$suspend) {
if ($tarif->vid == "hosting") {
$result=$plesk->unsuspendCustomer($order->panelUserId);
} else if ($tarif->vid == "reseller") {
$result=$plesk->unsuspendReseller($order->panelUserId);
}
}
else if ($suspend) {
if ($tarif->vid == "hosting") {
$result=$plesk->suspendCustomer($order->panelUserId);
} else if ($tarif->vid == "reseller") {
$result=$plesk->suspendReseller($order->panelUserId);
}
}
if ($result) {
$error = '';
} else {
$error = $plesk->error;
}
mconnect();
}
else if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,decodePwd($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->error;
}
mconnect();
}
else if ($server->type == "vdsmanager") {
$vdsmanager = new VDSManager;
$vdsmanager->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
if (!$suspend) {
$result=$vdsmanager->unSuspendVDS($order->serverlogin);
}
else if ($suspend) {
$result=$vdsmanager->suspendVDS($order->serverlogin);
}
if ($result) {
$error = '';
} else {
$error = $vdsmanager->error;
}
mconnect();
}
else if ($server->type == "gproxy") {
$gproxy = new GPROXY;
$gproxy->init(decodePwd($server->password));
if (!$suspend) {
$result = $gproxy->unSuspendProxy($order->panelUserId);
}
else if ($suspend) {
$result = $gproxy->suspendProxy($order->panelUserId);
}
if ($result) {
$error = '';
} else {
$error = $gproxy->error;
}
mconnect();
}
else if ($server->type == "gamecp") {
$gamecp = new GameCP;
$gamecp->init($server->ventrilo_url,decodePwd($server->password));
if (!$suspend) {
$result = $gamecp->unSuspendClient($order->panelUserId,$order->ventriloId);
}
else if ($suspend) {
$result = $gamecp->suspendClient($order->panelUserId,$order->ventriloId);
}
if ($result) {
$error = '';
} else {
$error = $gamecp->error;
}
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("/{userlogin}/ui","$user->login",$command);
$command = preg_replace("/{password}/ui",decodePwd($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);
$command = preg_replace("/{orderid}/ui","$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 if ($server->type == "rootpanel") {
$rootpanel = new ROOTPANELAPIH;
$rootpanel->init($server->ventrilo_url,$server->user,decodePwd($server->password));
if (!$suspend) {
$result = $rootpanel->unSuspendOrder($order->panelUserId);
}
else if ($suspend) {
$result = $rootpanel->suspendOrder($order->panelUserId);
}
mconnect();
if ($result) {
$error = "";
}
else {
$error = $rootpanel->error;
}
}
else { $error = "Операция не поддерживается для серверов с типом $server->type."; }
} 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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function changePackage($orderid, $newTarifId, $sendErrorEmail = 1) {
global $GLOBALerror, $dbhost, $dbuser, $dbpass, $dbname;
$order = GetOrderById($orderid);
$server = GetServers($order->serverid);
if ($order->id) {
$user=GetUserById($order->uid);
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 or $server->type == "gproxy" or $server->type == "gamecp") and ($server->user or $server->type == "gproxy" or $server->type == "gamecp") and ($server->password or $server->cpanelHash) and ($server->userip or $server->type == "hypervm" or $server->type == "hypervmxen" or $server->type == "vdsmanager" or $server->type == "gproxy" or $server->type == "gamecp" or $server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm")) or ($server->type == "ventrilo" or $server->type == "ventrilols" or $server->type == "teamspeak2" or $server->type == "teamspeak3")) {
if ($server->type == "ventrilo") {
$ventrilo = new Ventrilo($server->user,decodePwd($server->password),$server->ventrilo_resid);
$result = $ventrilo->adjustSlotsCount($newTarif->servername, $order->id);
if ($result) {
$error = "";
} else {
$error = $ventrilo->error;
}
mconnect();
}
else if ($server->type == "teamspeak2") {
$teamspeak = new TeamSpeak2($server->user,decodePwd($server->password));
$result = $teamspeak->adjustSlotsCount($order->serverlogin, $newTarif->servername);
if ($result) {
$error = "";
} else {
$error = $teamspeak->error;
}
mconnect();
}
else if ($server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm") {
$solusvm = new SolusVM();
$solusvm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$result = $solusvm->changePlan($order->ventriloId, $newTarif->servername);
if ($result) {
$error = "";
} else {
$error = $solusvm->error;
}
mconnect();
}
else if ($server->type == "hypervm" or $server->type == "hypervmxen") {
$hypervm = new HyperVM();
$hypervm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$result = $hypervm->changePackage($order->serverlogin, $newTarif->servername);
if ($result) {
$error = "";
} else {
$error = $hypervm->error;
}
mconnect();
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if (!$da->error) {
if ($order->serverid != $newTarif->serverid) {
if ($tarif->vid == "hosting") {
$tarifs_at_server = $da->get_packages();
} else if ($tarif->vid == "reseller") {
$tarifs_at_server = $da->get_packages_reseller();
}
}
if (($order->serverid == $newTarif->serverid) or @in_array($newTarif->servername,$tarifs_at_server)) {
if ($tarif->vid == "hosting") {
$result = $da->set_package_user($order->serverlogin,$newTarif->servername);
} else if ($tarif->vid == "reseller") {
$result = $da->set_package_reseller($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,decodePwd($server->password),$server->cpanelHash);
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 == "plesk") {
$plesk = new Plesk;
$plesk->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if ($order->serverid != $newTarif->serverid) {
$tarifs_at_server = $plesk->getClientTemplates();
$error = $plesk->error;
}
if (!$error) {
if (($order->serverid == $newTarif->serverid) or @in_array($newTarif->servername,$tarifs_at_server)) {
$result=$plesk->changePackage($order->panelUserId,$newTarif->servername);
if ($result) {
$error = '';
} else {
$error = $plesk->error;
}
} else {
$error = "На сервере отсутствует тарифный план $newTarif->servername.";
}
}
mconnect();
}
else if ($server->type == "plesk10") {
$plesk = new Plesk10;
$plesk->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if ($order->serverid != $newTarif->serverid) {
if ($tarif->vid == "hosting") {
$tarifs_at_server = $plesk->getServicePlans();
} else if ($tarif->vid == "reseller") {
$tarifs_at_server = $plesk->getResellerPlans();
}
$error = $plesk->error;
}
if (!$error) {
if (($order->serverid == $newTarif->serverid) or @in_array($newTarif->servername,$tarifs_at_server)) {
if ($tarif->vid == "hosting") {
$result=$plesk->switchSubscription($order->panelDomainId, $newTarif->servername);
} else if ($tarif->vid == "reseller") {
$result=$plesk->switchResellerPlan($order->panelUserId, $newTarif->servername);
}
if ($result) {
$error = '';
} else {
$error = $plesk->error;
}
} else {
$error = "На сервере отсутствует тарифный план $newTarif->servername.";
}
}
mconnect();
}
else if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
if ($order->serverid != $newTarif->serverid) {
$tarifs_at_server = $autoisp->getPackages();
$error = $autoisp->error;
}
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->error;
}
} else {
$error = "На сервере отсутствует тарифный план $newTarif->servername.";
}
}
mconnect();
}
else if ($server->type == "vdsmanager") {
$vdsmanager = new VDSManager;
$vdsmanager->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
if ($order->serverid != $newTarif->serverid) {
$tarifs_at_server = $vdsmanager->getPackages();
$error = $vdsmanager->error;
}
if (!$error) {
if (($order->serverid == $newTarif->serverid) or @in_array($newTarif->servername,$tarifs_at_server)) {
$result=$vdsmanager->changePackage($order->serverlogin,$newTarif->servername);
if ($result) {
$error = '';
} else {
$error = $vdsmanager->error;
}
} 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("/{userlogin}/ui","$user->login",$command);
$command = preg_replace("/{password}/ui",decodePwd($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);
$command = preg_replace("/{orderid}/ui","$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 = "Операция не поддерживается для серверов с типом $server->type"; }
} 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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function changeServer($orderid, $newServerId, $sendErrorEmail = 1) {
global $GLOBALerror, $dbhost, $dbuser, $dbpass, $dbname;
$order = GetOrderById($orderid);
$server = GetServers($order->serverid);
if ($order->id) {
$user=GetUserById($order->uid);
if ($order->serverlogin and $order->serverid) {
$tarif = GetTarifById($order->tarif);
$newServer = GetServers($newServerId);
if ($tarif->id) {
if ($newServer->id) {
if ($newServer->ventrilo_placeid or $server->type == "shellscript") {
if ($server->id) {
if (($server->type and ($server->ip or $server->type == "gproxy" or $server->type == "gamecp") and ($server->user or $server->type == "gproxy" or $server->type == "gamecp") and ($server->password or $server->cpanelHash) and ($server->userip or $server->type == "hypervm" or $server->type == "hypervmxen" or $server->type == "vdsmanager" or $server->type == "gproxy" or $server->type == "gamecp" or $server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm")) or ($server->type == "ventrilo" or $server->type == "ventrilols" or $server->type == "teamspeak2" or $server->type == "teamspeak3")) {
$error = "Операция не поддерживается для серверов с типом $server->type";
} else { $error = "Сервер настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Не найден сервер ID #$order->serverid."; }
} else { $error = "Не указано ID локации для сервера $newServer->name"; }
} else { $error = "Не найден сервер ID #$newServerId."; }
} 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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function changeSlots($orderid, $newSlots, $sendErrorEmail = 1) {
global $GLOBALerror, $dbhost, $dbuser, $dbpass, $dbname;
$order = GetOrderById($orderid);
$server = GetServers($order->serverid);
if ($order->id) {
$user=GetUserById($order->uid);
if ($order->serverlogin and $order->serverid) {
$tarif = GetTarifById($order->tarif);
if ($tarif->id) {
if ($server->id) {
if (($server->type and ($server->ip or $server->type == "gproxy" or $server->type == "gamecp") and ($server->user or $server->type == "gproxy" or $server->type == "gamecp") and ($server->password or $server->cpanelHash) and ($server->userip or $server->type == "hypervm" or $server->type == "hypervmxen" or $server->type == "vdsmanager" or $server->type == "gproxy" or $server->type == "gamecp" or $server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm")) or ($server->type == "ventrilo" or $server->type == "ventrilols" or $server->type == "teamspeak2" or $server->type == "teamspeak3")) {
if ($server->type == "gamecp") {
$gamecp = new GameCP;
$gamecp->init($server->ventrilo_url,decodePwd($server->password));
$result = $gamecp->changePlayers($order->panelUserId,$order->ventriloId,$newSlots);
if ($result) {
$error = '';
} else {
$error = $gamecp->error;
}
mconnect();
}
else {
$error = "Операция не поддерживается для серверов с типом $server->type";
}
} else { $error = "Сервер настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Не найден сервер ID #$order->serverid."; }
} 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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function changePassword($orderid, $newPassword, $sendErrorEmail = 1) {
global $GLOBALerror, $dbhost, $dbuser, $dbpass, $dbname;
$order = GetOrderById($orderid);
if ($order->id) {
if ($order->serverlogin and $order->serverid) {
$tarif = GetTarifById($order->tarif);
if ($tarif->id) {
$server = GetServers($order->serverid);
if ($server->id) {
if (($server->type and $server->ip and $server->user and ($server->password or $server->cpanelHash)) or ($server->type == "ventrilo" or $server->type == "ventrilols" or $server->type == "teamspeak2" or $server->type == "teamspeak3")) {
if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if (!$da->error) {
$result = $da->set_password($order->serverlogin,$newPassword);
if ($result) {
$error = "";
mconnect();
@mysql_query("update orders set serverpassword='".encodePwd($newPassword)."' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$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,decodePwd($server->password),$server->cpanelHash);
$result=$autowhm->changePassword($order->serverlogin,$newPassword);
if ($result) {
$error = '';
mconnect();
@mysql_query("update orders set serverpassword='".encodePwd($newPassword)."' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $autowhm->errors[0];
}
mconnect();
}
else if ($server->type == "plesk") {
$plesk = new Plesk;
$plesk->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$result=$plesk->changePassword($order->panelUserId,$order->panelDomainId,$newPassword);
if ($result) {
$error = '';
mconnect();
@mysql_query("update orders set serverpassword='".encodePwd($newPassword)."' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $plesk->error;
}
mconnect();
}
else if ($server->type == "plesk10") {
$plesk = new Plesk10;
$plesk->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if ($tarif->vid == "hosting") {
$result=$plesk->changeCustomerPassword($order->panelUserId, $newPassword);
} else if ($tarif->vid == "reseller") {
$result=$plesk->changeResellerPassword($order->panelUserId, $newPassword);
}
if ($result) {
$error = '';
mconnect();
@mysql_query("update orders set serverpassword='".encodePwd($newPassword)."' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $plesk->error;
}
mconnect();
}
else if ($server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm") {
$solusvm = new SolusVM();
$solusvm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$result = $solusvm->changeClientPassword($order->serverlogin,$newPassword);
if ($result) {
$error = '';
mconnect();
@mysql_query("update users set panelClientPassword='".encodePwd($newPassword)."' where id='$order->uid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$result2 = $solusvm->changeServerPassword($order->ventriloId,$newPassword);
if ($result2) {
$error = '';
mconnect();
@mysql_query("update orders set serverpassword='".encodePwd($newPassword)."' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $solusvm->error;
}
} else {
$error = $solusvm->error;
}
mconnect();
}
else if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
if ($tarif->vid == "hosting") {
$result=$autoisp->changePassword($order->serverlogin,$newPassword);
} else if ($tarif->vid == "reseller") {
$result=$autoisp->changeResellerPassword($order->serverlogin,$newPassword);
}
if ($result) {
$error = '';
mconnect();
@mysql_query("update orders set serverpassword='".encodePwd($newPassword)."' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $autoisp->error;
}
mconnect();
}
else if ($server->type == "shellscript") {
$command = $tarif->scriptPassword;
$reply = $tarif->scriptPasswordReply;
if ($command) {
$command = preg_replace("/{login}/ui","$order->serverlogin",$command);
$command = preg_replace("/{userlogin}/ui","$user->login",$command);
$command = preg_replace("/{password}/ui","$newPassword",$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);
$command = preg_replace("/{orderid}/ui","$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 = "";
mconnect();
@mysql_query("update orders set serverpassword='".encodePwd($newPassword)."' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
else { $error = "Биллингом был получен неудовлетворительный ответ для команды $command"; }
}
}
else { $error = "В тарифном плане ID # $tarif->id, $tarif->name не указан скрипт для изменения пароля."; }
}
else { $error = "Операция не поддерживается для северов с типом $server->type."; }
} else { $error = "Сервер настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Не найден сервер ID #$order->serverid."; }
} else { $error = "Не найден тарифный план ID #$order->tarif."; }
} else { $error = "Не указан логин на сервере или не выбран сервер для данного заказа."; }
} else { $error = "Не найден заказ ID #$orderid."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически сменить пароль ($newPassword) для аккаунта $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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function addExtraIPs($orderid, $ipsCount = 1, $sendErrorEmail = 1) {
global $GLOBALerror, $dbhost, $dbuser, $dbpass, $dbname;
$order = GetOrderById($orderid);
if ($order->id) {
if ($order->serverlogin and $order->serverid) {
$tarif = GetTarifById($order->tarif);
if ($tarif->id) {
$server = GetServers($order->serverid);
if ($server->id) {
if (($server->type and $server->ip and $server->user and ($server->password or $server->cpanelHash)) or ($server->type == "ventrilo" or $server->type == "ventrilols" or $server->type == "teamspeak2" or $server->type == "teamspeak3")) {
if ($server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm") {
$solusvm = new SolusVM();
$solusvm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$cnt = 0;
$extraips = array();
while ($cnt < $ipsCount) {
$cnt++;
$result = $solusvm->addExtraIP($order->ventriloId);
if ($result) {
$extraips[] = $result;
} else {
$error = $solusvm->error;
break;
}
}
mconnect();
if (@count($extraips) > 0) {
while (list($ipi,$ipv) = @each($extraips)) {
@mysql_query("update servers_ips set order_id='$order->id',isMain='0' where server_id='$order->serverid' and ip='$ipv'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
}
}
else { $error = "Операция не поддерживается для северов с типом $server->type."; }
} else { $error = "Сервер настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Не найден сервер ID #$order->serverid."; }
} else { $error = "Не найден тарифный план ID #$order->tarif."; }
} else { $error = "Не указан логин на сервере или не выбран сервер для данного заказа."; }
} else { $error = "Не найден заказ ID #$orderid."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически добавить выделенные IP для аккаунта $order->serverlogin на сервере для заказа ID #$orderid ($order->domain) по следующей причине:nn$errornnВам необходимо добавить IP вручную, а затем назначить их для заказа в редактировании заказа!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка при попытке добавить IP";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function restartUser($orderid, $sendErrorEmail = 1) {
global $GLOBALerror, $dbhost, $dbuser, $dbpass, $dbname;
$order = GetOrderById($orderid);
if ($order->id) {
$user=GetUserById($order->uid);
if ($order->serverlogin and $order->serverid) {
$tarif = GetTarifById($order->tarif);
if ($tarif->id) {
$server = GetServers($order->serverid);
if ($server->id) {
if (($server->type and $server->ip and $server->user and ($server->password or $server->cpanelHash)) or ($server->type == "ventrilo" or $server->type == "ventrilols" or $server->type == "teamspeak2" or $server->type == "teamspeak3")) {
if ($server->type == "shellscript") {
$command = $tarif->scriptRestart;
$reply = $tarif->scriptRestartReply;
if ($command) {
$command = preg_replace("/{login}/ui","$order->serverlogin",$command);
$command = preg_replace("/{userlogin}/ui","$user->login",$command);
$command = preg_replace("/{password}/ui",decodePwd($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);
$command = preg_replace("/{orderid}/ui","$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 if ($server->type == "hypervm" or $server->type == "hypervmxen") {
$hypervm = new HyperVM();
$hypervm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$result = $hypervm->restartServer($order->serverlogin);
if ($result) {
$error = "";
} else {
$error = $hypervm->error;
}
mconnect();
}
else if ($server->type == "vdsmanager") {
$vdsmanager = new VDSManager;
$vdsmanager->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
$result=$vdsmanager->restartVDS($order->serverlogin);
if ($result) {
$error = '';
} else {
$error = $vdsmanager->error;
}
mconnect();
}
else if ($server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm") {
$solusvm = new SolusVM();
$solusvm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$result = $solusvm->restartServer($order->ventriloId);
if ($result) {
$error = '';
} else {
$error = $solusvm->error;
}
mconnect();
}
else if ($server->type == "rootpanel") {
$rootpanel = new ROOTPANELAPIH;
$rootpanel->init($server->ventrilo_url,$server->user,decodePwd($server->password));
$result = $rootpanel->restartOrder($order->panelUserId);
mconnect();
if ($result) {
$error = "";
}
else {
$error = $rootpanel->error;
}
}
else { $error = "Операция не поддерживается для серверов с типом $server->type."; }
} else { $error = "Сервер настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Не найден сервер ID #$order->serverid."; }
} 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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function reinstallUser($orderid, $sendErrorEmail = 1) {
global $GLOBALerror, $dbhost, $dbuser, $dbpass, $dbname;
$order = GetOrderById($orderid);
if ($order->id) {
$user = GetUserById($order->uid);
if ($order->serverlogin and $order->serverid) {
$tarif = GetTarifById($order->tarif);
if ($tarif->id) {
$server = GetServers($order->serverid);
if ($server->id) {
if (($server->type and $server->ip and $server->user and ($server->password or $server->cpanelHash)) or ($server->type == "ventrilo" or $server->type == "ventrilols" or $server->type == "teamspeak2" or $server->type == "teamspeak3")) {
if ($server->type == "shellscript") {
$command = $tarif->scriptReinstall;
$reply = $tarif->scriptReinstallReply;
if ($command) {
$addons = GetAddonsIdsByTxt($order->addons);
while (list($kk,$vv) = @each($addons)) {
$oneAddon = GetAddonById($vv);
if ($oneAddon->id) {
$addons[$kk] = $oneAddon->textid;
} else {
$addons[$kk] = "";
}
}
if ($addons) {$addons = @join(":x:",$addons);} else {$addons = "";}
$command = preg_replace("/{login}/ui","$order->serverlogin",$command);
$command = preg_replace("/{userlogin}/ui","$user->login",$command);
$command = preg_replace("/{password}/ui",decodePwd($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);
$command = preg_replace("/{orderid}/ui","$order->id",$command);
$command = preg_replace("/{addons}/ui","$addons",$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 if ($server->type == "vdsmanager") {
$vdsmanager = new VDSManager;
$vdsmanager->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
$result=$vdsmanager->reinstallVDS($order->serverlogin);
if ($result) {
$error = '';
} else {
$error = $vdsmanager->error;
}
mconnect();
}
else if ($server->type == "solusvmopenvz" or $server->type == "solusvmxen" or $server->type == "solusvmxenhvm" or $server->type == "solusvmkvm") {
$solusvm = new SolusVM();
$solusvm->init($server->protocol,$server->ip,$server->user,decodePwd($server->password));
$addons = GetAddonsIdsByTxt($order->addons);
if ($addons) {
while (list($k,$v) = each($addons)) {
$addon = GetAddonById($v);
if ($addon->isOs) {
$os = $addon->textid;
break;
}
}
}
$result = $solusvm->reinstallServer($order->ventriloId, $os);
if ($result) {
$error = '';
} else {
$error = $solusvm->error;
}
mconnect();
}
else if ($server->type == "rootpanel") {
$rootpanel = new ROOTPANELAPIH;
$rootpanel->init($server->ventrilo_url,$server->user,decodePwd($server->password));
$result = $rootpanel->reinstallOrder($order->panelUserId);
mconnect();
if ($result) {
$error = "";
}
else {
$error = $rootpanel->error;
}
}
else { $error = "Операция не поддерживается для серверов с типом $server->type."; }
} else { $error = "Сервер настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Не найден сервер ID #$order->serverid."; }
} 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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$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 title='$_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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$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());
if (GetSetting("smsGateway")) {
$smsmsg = "Nuzhno proverit profile #$object->id for user #$user->id, $user->login";
$admIds=GetAdminIdsWhereTrueParam("sms_sendprofilecheck");
while (list($i,$aid) = @each($admIds)) {
sendSMS('',$aid,$smsmsg);
}
}
return false;
}
return false;
} else {
return true;
}
}
}
function checkProfile($type, $userid='', $profileid='', $requiredFields='') {
# $type:
# not - не проверяем ничего, кроме email
# min - проверка минимального кол-ва полей, необходимых для регистрации com/net/org и т.п.
# max - проверка всех полей, включая паспортные данные, необходимых для регистрации ru/su
global $GLOBALerror, $GLOBALerrorFields, $_lang, $isAPI, $isR, $isD, $isPPUA, $rF, $org, $surname, $name, $otchestvo, $firma, $firmaeng, $country, $oblast, $post, $city, $street, $komu, $address_org, $phone, $mobile, $fax, $email, $seriya, $by, $date, $birthday, $inn, $kpp, $okonh, $okpo, $bank, $bank_schet, $bank_bik, $edrpou, $passportFiles, $socstrahnumber, $idnum, $ogrn, $ogrn_by, $ogrn_date, $icq, $skype, $ripe, $ripe, $uanic, $dpnic, $epnic, $eunic;
if (is_array($requiredFields)) { $rF = $requiredFields; }
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;
$mobile = $object->mobile;
$fax = $object->fax;
$email = $object->email;
$icq = $object->icq;
$skype = $object->skype;
$ripn = $object->ripn;
$ripe = $object->ripe;
$uanic = $object->uanic;
$eunic = $object->eunic;
$dpnic = $object->dpnic;
$epnic = $object->epnic;
$okonh = $object->okonh;
$okpo = $object->okpo;
$bank = $object->bank;
$bank_schet = $object->bank_schet;
$bank_bik = $object->bik;
$edrpou = $object->edrpou;
$passportFiles = $object->passportFiles;
$socstrahnumber = $object->socstrahnumber;
$idnum = $object->idnum;
$ogrn = $object->ogrn;
$ogrn_by = $object->ogrn_by;
$ogrn_date = mydate($object->ogrn_date);
$icq = $object->icq;
$ripe = $object->ripe;
$ripe = $object->ripe;
$uanic = $object->uanic;
$dpnic = $object->dpnic;
$epnic = $object->epnic;
$eunic = $object->eunic;
}
$profilePassportDisabled = GetSetting("profilePassportDisabled");
$profileTypes=GetSetting("profileTypes"); $profileTypes=mb_split("::",$profileTypes);
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]; $ff[] = "org"; }
# if ($type != "not" and !@in_array($org,$profileTypes)) { $f[] = $_lang[ProfileUserType]; $ff[] = "org"; }
if ($type != "not" and (strlen($country) != 2 or $_lang[Country][$country] == "")) { $f[] = $_lang[ProfileCountry]; $ff[] = "country"; }
# Проверка общих полей
if ($type != "not" and mb_strlen($surname) < 3) { $f[] = $_lang[ProfileSurname]; $surname=""; $ff[] = "surname"; }
if ($type != "not" and mb_strlen($name) < 2) { $f[] = $_lang[ProfileName]; $name=""; $ff[] = "name"; }
if ($type != "not" and mb_strlen($otchestvo) < 3) { $f[] = $_lang[ProfileOtchestvo]; $otchestvo=""; $ff[] = "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=""; $ff[] = "seriya"; }
else if ($type == "max" and $country == "UA" and !preg_match("/^D{2} d{6}$/u",$seriya)) { $f[] = $_lang[ProfilePassportSeriya]; $seriya=""; $ff[] = "seriya"; }
else if ($type == "max" and $country == "BY" and !preg_match("/^D{2} d{7}$/u",$seriya)) { $f[] = $_lang[ProfilePassportSeriya]; $seriya=""; $ff[] = "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=""; $ff[] = "seriya";}
if ($type == "max" and mb_strlen($by) < 10) { $f[] = $_lang[ProfilePassportVidan]; $by=""; $ff[] = "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"; $ff[] = "date"; }
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"; $ff[] = "birthday"; }
}
if ($org == "2") {
if ($country == "UA") {
if ($type == "max" and (preg_match("/[D]+/u",$edrpou) or strlen($edrpou) != 10)) { $f[] = $_lang[ProfileEdrpou]; $edrpou=""; $ff[] = "edrpou"; }
}
if ($country == "RU") {
if ($type == "max" and ((preg_match("/[D]+/u",$inn) or (strlen($inn) != 10 and strlen($inn) != 12)))) { $f[] = $_lang[ProfileInn]; $inn=""; $ff[] = "inn"; }
}
}
if ($country == "BY") {
if ($type == "max" and (!$idnum or preg_match("/[D]+/u",$idnum))) { $f[] = $_lang[ProfilePassportIdnum]; $idnum=""; $ff[] = "idnum"; }
}
}
if ($country == "FI" and $org == "1") {
if ($type == "max" and !preg_match("/^d{6}-d{3}w{1}$/u",$socstrahnumber)) { $f[] = $_lang[ProfileSocStrahNumber]; $socstrahnumber=""; $ff[] = "socstrahnumber"; }
}
if ($country == "HU" and $org == "2") {
if ($type == "max" and !$ogrn) { $f[] = $_lang[ProfileRegNumberPP]; $ogrn=""; $ff[] = "ogrn"; }
}
$passportFilesEnable = GetSetting("passportFilesEnable");
$passportFilesRequired = GetSetting("passportFilesRequired");
if ($passportFilesEnable and !$profilePassportDisabled and !$isAPI) {
if (!$passportFiles) {
if (($passportFilesRequired == "ru" and $isR) or ($passportFilesRequired == "domains" and ($isD or $isR)) or ($passportFilesRequired == "max" and $type == "max")) { $f[] =$_lang[ProfilePassportFiles]; $ff[] = "passportFiles"; }
}
}
# Проверка полей организации
if ($org == "3" or ($org == "2" and ($country == "FI" or $country == "BY"))) {
if (!($org == "2" and $country == "BY")) {
if ($type != "not" and mb_strlen($firma) < 6) { $f[] = $_lang[ProfileOrg]; $firma=""; $ff[] = "firma"; }
if ($country != "FI") {
if ($type != "not" and strlen($firmaeng) < 6) { $f[] = $_lang[ProfileOrgEng]; $firmaeng=""; $ff[] = "firmaeng"; }
}
if ($type != "not" and mb_strlen($address_org) < 15) { $f[] = $_lang[ProfileYuridAddress]; $address_org=""; $ff[] = "address_org"; }
}
if ($country == "UA" or $country == "RU") {
if ($type == "max" and ((preg_match("/[D]+/u",$inn) or (strlen($inn) != 10 and strlen($inn) != 12)))) { $f[] = $_lang[ProfileInn]; $inn=""; $ff[] = "inn"; }
} else if ($country == "BY") {
if ($type == "max" and ((preg_match("/[D]+/u",$inn) or strlen($inn) != 9))) { $f[] = $_lang[ProfileInn]; $inn=""; $ff[] = "inn"; }
} else {
if ($type == "max" and (!$inn or preg_match("/[D]+/u",$inn))) { $f[] = $_lang[ProfileInn]; $inn=""; $ff[] = "inn";}
}
if ($country == "RU") {
if ($type == "max" and ((preg_match("/[D]+/u",$kpp) or strlen($kpp) != 9))) { $f[] = $_lang[ProfileKpp]; $kpp=""; $ff[] = "kpp"; }
if ($type == "max" and ((preg_match("/[D]+/u",$okonh) or mb_strlen($okonh) < 3))) { $f[] = $_lang[ProfileOkonh]; $okonh=""; $ff[] = "okonh"; }
}
if ($country == "BY") {
if ($type == "max" and (!$okpo or preg_match("/[D]+/u",$okpo))) { $f[] = $_lang[ProfileOkpo]; $okpo=""; $ff[] = "okpo"; }
}
if ($country == "FI") {
if ($type == "max" and !preg_match("/d{7}-d{1}/u",$ogrn)) { $f[] = $_lang[ProfileOgrn]; $ogrn=""; $ff[] = "ogrn"; }
} else {
if ($type == "max" and !$ogrn) { $f[] = $_lang[ProfileOgrn]; $ogrn=""; $ff[] = "ogrn";}
}
if ($type == "max" and !$ogrn_by) { $f[] = $_lang[ProfileOgrnBy]; $ogrn_by=""; $ff[] = "ogrn_by";}
if ($type == "max" and (!preg_match("/^d{2}.d{2}.d{4}$/u",$ogrn_date) or $ogrn_date == "00.00.0000")) { $f[] = $_lang[ProfileOgrnDate]; $ogrn_date="00.00.0000"; $ff[] = "ogrn_date"; }
}
# Проверка общих полей
if ($type != "not" and ($country == "RU" or $country == "UA" or $country == "BY" or $country == "KZ") and !$oblast) { $f[] = $_lang[ProfileOblast]; $oblast=""; $ff[] = "oblast"; }
if ($type != "not" and mb_strlen($post) < 4) { $f[] = $_lang[ProfileIndex]; $post=""; $ff[] = "post"; }
if ($type != "not" and mb_strlen($city) < 3) { $f[] = $_lang[ProfileCity]; $city=""; $ff[] = "city"; }
else if ($type != "not" and (preg_match("/^г /iu", $city) or preg_match("/^г./iu", $city) or preg_match("/^город /iu", $city))) { $f[] = $_lang[ProfileCity]; $city=""; $ff[] = "city"; }
if ($type != "not" and mb_strlen($street) < 5) { $f[] = $_lang[ProfileAddress]; $street=""; $ff[] = "street"; }
if ($type != "not" and $country != "FI" and !$komu) { $f[] = $_lang[ProfileKomu]; $komu=""; $ff[] = "komu"; }
if ($type != "not" and (!preg_match("/^+d+s{1}d+s{1}d+$/u",$phone) or strlen($phone) < 8)) { $f[] = $_lang[ProfilePhone]; $phone=""; $ff[] = "phone"; }
if (@in_array("mobile",$rF) and (!preg_match("/^+d+s{1}d+s{1}d+$/u",$mobile) or strlen($mobile) < 8)) { $f[] = $_lang[ProfileMobile]; $mobile=""; $ff[] = "mobile"; }
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=""; $ff[] = "fax"; }
if (!valid_email($email)) { $f[] = $_lang[ProfileEmail]; $email=""; $ff[] = "email"; }
if (count($f) > 0) { $GLOBALerror = $_lang[ProfileErrorFields].": ".@join(", ",$f);}
if (count($ff) > 0) { $GLOBALerrorFields = @join(", ",$ff);}
if ($GLOBALerror or $GLOBALerrorFields) { return false; }
else {return true;}
}
function regDomain($domain_id, $period, $sendErrorEmail = 1) {
global $GLOBALerror, $isAPI, $full_home_path, $onlinenicDomainTypes, $nicruService, $nicruTemplate, $startedRegion, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$domainWithoutZone = mb_split(".",$domain->domain); $domainWithoutZone = $domainWithoutZone[0];
$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 (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$isR = 1; $chkProfile = "max";
} else {
$isD = 1;
$chkProfile = GetSetting("checkprofiletype");
if (mb_strtolower($zone->zone) == "pp.ua") { $rF[] = "mobile"; }
}
if (checkProfile($chkProfile, $user->id, $domain->profileId, $rF)) {
if (checkProfileByAdmin($user->id, $domain->profileId)) {
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$profile = GetUserProfileByUserId($localContactUser->id, $zone->localContact);
} else {
$profile = GetUserProfileByUserId($user->id, $domain->profileId);
}
$profile->email = mb_strtolower($profile->email);
if (!$domain->privacy and $zone->privacy and $zone->privacy_required and !($zone->privacy == "person" and $profile->org == "3")) {
$domain->privacy = 1;
@mysql_query("update orders_domains set privacy=1 where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
if ($registrator->type != "started" and $registrator->type != "r01" and $registrator->type != "rootpanel") {
$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);
$ns1ip=trim($domain->ns1ip);
$ns2ip=trim($domain->ns2ip);
$ns3ip=trim($domain->ns3ip);
$ns4ip=trim($domain->ns4ip);
}
if ($ns1 and $ns2) {
if ($registrator->type and $domain->defaultNSFlag and $zone->enableDefaultNS) {
if ($zone->enableCreateZone) {
if (createDomainZoneAtServer($domain_id, $ns1, $ns2, $ns3, $ns4, $sendErrorEmail)) {
$error = "";
} else {
$error = $GLOBALerror;
}
}
}
$defaultDnsServer1 = GetSetting("defaultDnsServer1");
$defaultDnsServer2 = GetSetting("defaultDnsServer2");
if (!$error) {
if ($registrator->type == "regru") {
$regru_url = $registrator->url;
$regru_user = $registrator->text1;
$regru_password = decodePwd($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 (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$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);
if ($domain->privacy) {
$private_person_flag = "1";
} else {
$private_person_flag = "0";
}
$result=$regru->regRuDomainPerson($domain->domain,$period,$regru_fail_if_no_money,$regru_no_bill_notify,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$person,$private_person_flag,$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,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$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) = mb_split(" ", $profile->phone);
$o_phone = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) {
list($faxNoCc,$faxNo1,$faxNo2) = mb_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,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$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' 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 = decodePwd($registrator->text2);
if ($webnames_url and $webnames_user and $webnames_password) {
$webnames = new WEBNAMES;
$webnames->init($webnames_url,$webnames_user,$webnames_password);
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$p_addr = $profile->post.", ".$profile->city.", ".$profile->street;
$residence = $p_addr;
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);
if ($domain->privacy) {
$private_person_flag = "1";
} else {
$private_person_flag = "0";
}
$result=$webnames->regRuDomainPerson($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$person,$private_person_flag,$person_r,$passport,$birth_date,$profile->country,$p_addr,$residence,$profile->phone,$profile->fax,$profile->email,$profile->inn);
} else if ($profile->org == "3") {
$result=$webnames->regRuDomainOrg($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$profile->firmaeng,$profile->firma,$profile->inn,$profile->kpp,$profile->country,$profile->address_org,$p_addr,$profile->phone,$profile->fax,$profile->email,$profile->ogrn);
}
} else if (mb_strtolower($zone->zone) == "kz" or mb_strtolower($zone->zone) == "uz" or mb_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) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; }
$result=$webnames->regKzUzTjDomain($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$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) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; }
$o_addr = GotoTranslit($profile->street);
$o_city = GotoTranslit($profile->city);
$o_state = GotoTranslit($profile->oblast);
if (mb_strtolower($zone->zone) == "asia") { $default_ced = "1"; } else { $default_ced = ""; }
$result=$webnames->regOtherDomain($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$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' 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") {
$naunet_url = $registrator->url;
$naunet_user = $registrator->text1;
$naunet_password = decodePwd($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;}
$login_addon=mt_rand();
$login_addon=substr($login_addon,0,3);
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$naunetLogin = $localContactUser->login . $login_addon;
} else {
$naunetLogin = $user->login . $login_addon;
}
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 ($domain->privacy) {
$privatePerson = "yes";
} else {
$privatePerson = "no";
}
if (!$profile->naunetLogin) {
$result=$naunet->regDomainNewPerson($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$person,$person_r,$passport,$birth_date,$address_r,$p_addr,$profile->phone,$profile->fax,$profile->email,$profile->inn,$privatePerson,$naunetLogin);
} else {
$result=$naunet->regDomainExistsPerson($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$profile->naunetLogin,$privatePerson);
}
} else if ($profile->org == "3") {
if (!$profile->naunetLogin) {
$result=$naunet->regDomainNewOrg($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$profile->firmaeng,$profile->firma,$profile->inn,$profile->address_org,$p_addr,$profile->phone,$profile->fax,$profile->email,$naunetLogin);
} else {
$result=$naunet->regDomainExistsOrg($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$profile->naunetLogin);
}
}
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' 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='$naunetLogin' 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 if ($registrator->type == "activeby") {
$activeby_url = $registrator->url;
$activeby_password = decodePwd($registrator->text2);
$activeby_ssl = $registrator->text3;
$activeby_log = $registrator->check1;
if ($activeby_url and $activeby_ssl and $activeby_password) {
$activeby = new ACTIVEBY;
$activeby->init($activeby_url,$activeby_ssl,$activeby_password,$activeby_log);
if ($profile->activebyAccountId) { $activebyAccountId = $profile->activebyAccountId; }
if (!$activebyAccountId) {
$login_addon=mt_rand();
$login_addon=substr($login_addon,0,3);
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$activebyLogin = $localContactUser->login . $login_addon;
} else {
$activebyLogin = $user->login . $login_addon;
}
$pw = generatePassword(8);
$country_id = strtolower($country_id);
$email = $profile->email;
if ($profile->org == "2") { $company_name = "ИП ".$profile->surname." ".$profile->name." ".$profile->otchestvo; } else if ($profile->org == "3") { $company_name = $profile->org; } else { $company_name = ""; }
$first_name = $profile->name;
$last_name = $profile->surname;
$middle_name = $profile->otchestvo;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = @mb_split(" ", $profile->fax); $fax_country_code = $faxNoCc; $fax_area_code = $faxNo1; $fax_number = $faxNo2; }
if ($profile->phone) { list($telNoCc,$telNo1,$telNo2) = @mb_split(" ", $profile->phone); $phone_country_code = $telNoCc; $phone_area_code = $telNo1; $phone_number = $telNo2; }
$address = $profile->street;
$state = $profile->oblast;
if ($profile->org == "1") { $type = 1; } else if ($profile->org == "2") { $type = 3; } else if ($profile->org == "3") { $type = 2; }
if ($profile->birthday) { $birthday = @mb_split("-", $profile->birthday); $birthday = mktime(0,0,0,$birthday[1],$birthday[2],$birthday[0]); }
$zip = $profile->post;
$city = $profile->city;
if ($profile->org == "1" or $profile->org == "2") {
$PassportNumber = $profile->passport_seriya;
$PassportByAndDate = $profile->pasport_by.", ".mydate($profile->pasport_date);
}
if ($profile->org == "2" or $profile->org == "3") {
$d60_number = $profile->ogrn;
$d60_authority = $profile->ogrn_by;
$d60_date = mydate($profile->ogrn_date);
$UNP = $profile->inn;
$OKPO = $profile->okpo;
$BankAccount = $profile->bank_schet;
$BankName = $profile->bank;
$BankCode = $profile->bank_bik;
}
$activebyAccountId = $activeby->createAccount($country_id, $email, $company_name, $first_name, $last_name, $middle_name, $fax_area_code, $fax_country_code, $fax_number, $phone_area_code, $phone_country_code, $phone_number, $address, $state, $type, $birthday, $zip, $city, $PassportNumber, $PassportByAndDate, $d60_number, $d60_authority, $UNP, $OKPO, $BankAccount, $BankName, $BankCode, $d60_date);
if ($activebyAccountId) {
mconnect();
@mysql_query("update users_profile set activebyAccountId='$activebyAccountId' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$activeby->createUser($activebyAccountId, $country_id, $email, $first_name, $last_name, $middle_name, $activebyLogin, $pw, $phone_country_code." ".$phone_area_code." ".$phone_number, $zip);
}
}
if ($activebyAccountId and !$activeby->error) {
$result=$activeby->registerDomain($domain->domain, $activebyAccountId, $zone->promo);
mconnect();
if ($result[subscription_id]) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',activebySubscriptionId='".$result[subscription_id]."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $activeby->error;
}
}
else {
$error = $activeby->error;
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, файл сертификата или пароль для $registrator->name"; }
}
else if ($registrator->type == "nicru") {
$nicru_url = $registrator->url;
$nicru_user = $registrator->text1;
$nicru_password = decodePwd($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 = mb_strtolower($zone->zone);
$service = $nicruService[$zidx];
$ntemplate = $nicruTemplate[$zidx];
if ($service and $ntemplate) {
if ($domain->privacy) {
$private_person = "ON";
} else {
$private_person = "OFF";
}
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$orderId = $nicru->regRuDomain($anketaId,$service,$ntemplate,$domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,"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,$ntemplate,$domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
}
}
mconnect();
if ($orderId) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',nicruOrderId='$orderId',panel_url='https://www.nic.ru/manager/',panel_user='$anketaId',panel_pwd='".encodePwd($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 = decodePwd($registrator->text2);
$freehost_nichandle = $registrator->text3;
if ($freehost_url and $freehost_port and $freehost_user and $freehost_password) {
$nichandle = $profile->uanic;
if (!$nichandle) {
$hm = GetFirstActiveRegistratorByType("hostmaster");
if ($hm->id) {
$hostmaster_url = $hm->url;
$hostmaster_port = $hm->port;
$hostmaster_user = $hm->text1;
$hostmaster_password = decodePwd($hm->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);
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) {
$nichandle = $nichandle."-UANIC";
@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;
}
$hostmaster->disconnect();
}
} else {
$nichandle = $freehost_nichandle;
}
}
if (!$error) {
if ($nichandle) {
$freehost = new FREEHOST;
$freehost->init($freehost_url,$freehost_port,$freehost_user,$freehost_password);
$result=$freehost->registerDomain($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$nichandle);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' 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 = decodePwd($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);
if ($nichandle) {
mconnect();
@mysql_query("update users_profile set uanic='$nichandle-UANIC' 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) {
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
if ($ns1 and !$ns1ip and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns1); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns1,"1.1.1.1"); } }
if ($ns2 and !$ns2ip and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns2); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns2,"1.1.1.1"); } }
if ($ns3 and !$ns3ip and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns3); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns3,"1.1.1.1"); } }
if ($ns4 and !$ns4ip and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns4); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns4,"1.1.1.1"); } }
if ($defaultDnsServer1 and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($defaultDnsServer1); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($defaultDnsServer1,"1.1.1.1"); } }
if ($defaultDnsServer2 and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($defaultDnsServer2); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($defaultDnsServer2,"1.1.1.1"); } }
if (!$hostmaster->error) {
$result=$hostmaster->registerDomain($domain->domain,$defaultDnsServer1,$defaultDnsServer2,'','',$nichandle,$domain->license);
}
}
else {
if ($ns1 and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns1); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns1,"1.1.1.1"); } }
if ($ns2 and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns2); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns2,"1.1.1.1"); } }
if ($ns3 and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns3); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns3,"1.1.1.1"); } }
if ($ns4 and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns4); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns4,"1.1.1.1"); } }
if (!$hostmaster->error) {
$result=$hostmaster->registerDomain($domain->domain,$ns1,$ns2,$ns3,$ns4,$nichandle,$domain->license);
}
}
if ($result) {
mconnect();
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($isOwnNS) {
if (!$hostmaster->error and $ns1ip) { $hostmaster->createNS($ns1, $ns1ip); }
if (!$hostmaster->error and $ns2ip) { $hostmaster->createNS($ns2, $ns2ip); }
if (!$hostmaster->error and $ns3ip) { $hostmaster->createNS($ns3, $ns3ip); }
if (!$hostmaster->error and $ns4ip) { $hostmaster->createNS($ns4, $ns4ip); }
if (!$hostmaster->error) {
if ($hostmaster->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4)) {
$error = "";
} else {
$error = $hostmaster->error;
}
} else {
$error = $hostmaster->error;
}
} else {
$error = "";
}
} else {
$error = $hostmaster->error;
}
}
$hostmaster->disconnect();
mconnect();
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "hostmasterepp") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($registrator->text2);
$hostmaster_ssl = $registrator->text3;
$hostmaster_log = $registrator->check1;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTEREPP;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password,$hostmaster_ssl,$hostmaster_log);
$contactId = $domain->hostmasterEppContactId;
if (!$contactId) {
$name = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($profile->otchestvo,0,1))." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng; } else if ($profile->firma) { $org = GotoTranslit($profile->firma); } else { $org = ""; }
$address = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; } else { $faxNo = ""; }
# if ($domain->privacy) { $disclose = 0; } else { $disclose = 1; }
$disclose = 0;
$contactId = $hostmaster->createContact($name, $org, $address, $city, $oblast, $profile->post, $profile->country, $telNo, $faxNo, $profile->email, $disclose);
if ($contactId) {
mconnect();
@mysql_query("update orders_domains set hostmasterEppContactId='$contactId' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $hostmaster->error;
}
}
if (!$error) {
$authinfo = generatePassword(8);
$result = $hostmaster->registerDomain($domain->domain, $period, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip, $contactId, $authinfo, $domain->license);
if ($result) {
if ($result == "ok") { $registrarDomainStatus = 1; } else if ($result == "pending") { $registrarDomainStatus = 3;}
mconnect();
@mysql_query("update orders_domains set status='$registrarDomainStatus',autoregby='$zone->autoreg',transferAuth='$authinfo' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $hostmaster->error;
}
}
$hostmaster->logout();
mconnect();
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "nicdpua") {
$nicdpua_url = $registrator->url;
$nicdpua_port = $registrator->port;
$nicdpua_user = $registrator->text1;
$nicdpua_password = decodePwd($registrator->text2);
$nicdpua_ssl = $registrator->text3;
$nicdpua_log = $registrator->check1;
if ($nicdpua_url and $nicdpua_port and $nicdpua_user and $nicdpua_password) {
$nicdpua = new NICDPUA;
$nicdpua->init($nicdpua_url,$nicdpua_port,$nicdpua_user,$nicdpua_password,$nicdpua_ssl,$nicdpua_log);
$contactId = $domain->nicdpuaContactId;
if (!$contactId) {
$name = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($profile->otchestvo,0,1))." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng; } else if ($profile->firma) { $org = GotoTranslit($profile->firma); } else { $org = ""; }
$address = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; } else { $faxNo = ""; }
# if ($domain->privacy) { $disclose = 0; } else { $disclose = 1; }
$disclose = 0;
$contactId = $nicdpua->createContact($name, $org, $address, $city, $oblast, $profile->post, $profile->country, $telNo, $faxNo, $profile->email, $disclose);
if ($contactId) {
mconnect();
@mysql_query("update orders_domains set nicdpuaContactId='$contactId' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $nicdpua->error;
}
}
if (!$error) {
$authinfo = generatePassword(8);
$result = $nicdpua->registerDomain($domain->domain, $period, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip, $contactId, $authinfo, $domain->license);
if ($result) {
if ($result == "ok") { $registrarDomainStatus = 1; } else if ($result == "pending") { $registrarDomainStatus = 3;}
mconnect();
@mysql_query("update orders_domains set status='$registrarDomainStatus',autoregby='$zone->autoreg',transferAuth='$authinfo' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $nicdpua->error;
}
}
$nicdpua->logout();
mconnect();
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "hosterby") {
$hosterby_url = $registrator->url;
$hosterby_port = $registrator->port;
$hosterby_user = $registrator->text1;
$hosterby_password = decodePwd($registrator->text2);
$hosterby_log = $registrator->check1;
if ($hosterby_url and $hosterby_port and $hosterby_user and $hosterby_password) {
$hosterby = new HOSTERBY;
$hosterby->init($hosterby_url,$hosterby_port,$hosterby_user,$hosterby_password,$hosterby_log);
$contactId = $domain->hosterbyContactId;
if (!$contactId) {
if ($profile->org == "3") { $type = "organization"; $name = $profile->firmaeng; }
else { $type = "person"; $name = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($profile->otchestvo,0,1))." ".GotoTranslit($profile->surname); }
$address = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
$contactId = $hosterby->createContact($name, $address, $city, $profile->post, $profile->country, $telNo, $profile->email, $type);
if ($contactId) {
mconnect();
@mysql_query("update orders_domains set hosterbyContactId='$contactId' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $hosterby->error;
}
}
if (!$error) {
$result = $hosterby->registerDomain($domain->domain, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip, $contactId);
if ($result) {
mconnect();
@mysql_query("update orders_domains set status='1',autoregby='$zone->autoreg' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $hosterby->error;
}
}
$hosterby->logout();
mconnect();
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "networking4all") {
$n4all_url = $registrator->url;
$n4all_user = $registrator->text1;
$n4all_password = decodePwd($registrator->text2);
$n4all_handle = $registrator->text3;
if ($n4all_url and $n4all_user and $n4all_password and $n4all_handle) {
$n4all = new NETWORKING4ALL;
$n4all->init($n4all_url,$n4all_user,$n4all_password,$n4all_handle);
$contactId = $domain->networking4allContactId;
if (!$contactId) {
$initials = GotoTranslit(mb_substr($profile->name,0,1)).".";
$firstName = GotoTranslit($profile->name);
$middleName = GotoTranslit($profile->otchestvo);
$lastName = GotoTranslit($profile->surname);
$street = GotoTranslit($profile->street);
$postalCode = $profile->post;
$city = GotoTranslit($profile->city);
if ($profile->oblast) { $province = GotoTranslit($profile->oblast); } else { $province = $city; }
$countryCode = $profile->country;
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $phoneNumber = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNumber = $faxNoCc.".".$faxNo1."".$faxNo2; } else { $faxNumber = ""; }
if ($profile->mobile) { list($mobNoCc,$mobNo1,$mobNo2) = mb_split(" ", $profile->mobile); $mobileNumber = $mobNoCc.".".$mobNo1."".$mobNo2; } else { $mobileNumber = ""; }
$email = $profile->email;
$contactId = $n4all->createContact($initials, $firstName, $middleName, $lastName, $street, $postalCode, $city, $province, $countryCode, $phoneNumber, $faxNumber, $mobileNumber, $email);
mconnect();
if ($contactId) {
@mysql_query("update orders_domains set networking4allContactId='$contactId' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $n4all->error;
}
}
if (!$error) {
$result = $n4all->registerDomain($domain->domain, $contactId, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status='1',autoregby='$zone->autoreg' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $n4all->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "onlinenic") {
$onlinenic_url = $registrator->url;
$onlinenic_port = $registrator->port;
$onlinenic_user = $registrator->text1;
$onlinenic_password = decodePwd($registrator->text2);
if ($onlinenic_url and $onlinenic_port and $onlinenic_user and $onlinenic_password) {
$zidx = mb_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) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; } else { $faxNo = $telNo; }
$pw = generatePassword(8,1);
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
$contactId = $onlinenic->regDomain($domain->domain,$period,$defaultDnsServer1,$defaultDnsServer2,'','',$domaintype,$name,$company,$street1,"",$city,"NA",$profile->post,$profile->country,$telNo,$faxNo,$profile->email,$pw);
}
else {
$contactId = $onlinenic->regDomain($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$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',panel_url='https://www.onlinenic.com/cgi-bin/english/correct_domain_new.cgi',panel_user='$domain->domain',panel_pwd='".encodePwd($pw)."' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($isOwnNS) {
if ($ns1ip) { $onlinenic->createNS($domaintype, $ns1, $ns1ip); }
if (!$onlinenic->error and $ns2ip) { $onlinenic->createNS($domaintype, $ns2, $ns2ip); }
if (!$onlinenic->error and $ns3ip) { $onlinenic->createNS($domaintype, $ns3, $ns3ip); }
if (!$onlinenic->error and $ns4ip) { $onlinenic->createNS($domaintype, $ns4, $ns4ip); }
if (!$onlinenic->error) {
if ($onlinenic->updateNS($domain->domain,$domaintype,$ns1,$ns2,$ns3,$ns4,$pw)) {
$error = "";
} else {
$error = $onlinenic->error;
}
}
else {
$error = $onlinenic->error;
}
}
else {
$error = "";
}
} else {
$error = $onlinenic->error;
}
}
else { $error = "Авторегистрация не возможна, т.к. через $registrator->name не поддерживается регистрация доменов в зоне ".$zone->zone."."; }
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "directi") {
$directi_url = $registrator->url;
$directi_user = $registrator->text1;
$directi_password = decodePwd($registrator->text2);
$directi_log = $registrator->check1;
if ($directi_url and $directi_user and $directi_password) {
$directi = new DIRECTI;
$directi->init($directi_url,$directi_user,$directi_password,$directi_log);
$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);
$state = GotoTranslit($profile->oblast);
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $telNoCc = preg_replace("/+/ui","",$telNoCc); $telNo = $telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNoCc = preg_replace("/+/ui","",$faxNoCc); $faxNo = $faxNo1."".$faxNo2; }
if ($profile->mobile) { list($mobileNoCc,$mobileNo1,$mobileNo2) = mb_split(" ", $profile->mobile); $mobileNoCc = preg_replace("/+/ui","",$mobileNoCc); $mobileNo = $mobileNo1."".$mobileNo2; }
$langPref = "ru";
$customerId = $directi->signUp($profile->email, generatePassword(8,1), $name, $company, $address1, "", "", $city, $state, $profile->country, $profile->post, $telNoCc, $telNo, "", "", $faxNoCc, $faxNo, $langPref, $mobileNoCc, $mobileNo);
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 = $directi->error;
}
}
if ($customerId) {
if (preg_match("/.coop$/ui",$domain->domain)) {
$contactType = "CoopContact";
} else if (preg_match("/.uk$/ui",$domain->domain)) {
$contactType = "UkContact";
} else if (preg_match("/.eu$/ui",$domain->domain)) {
$contactType = "EuContact";
} else if (preg_match("/.cn$/ui",$domain->domain)) {
$contactType = "CnContact";
} else if (preg_match("/.co$/ui",$domain->domain)) {
$contactType = "CoContact";
} else if (preg_match("/.ca$/ui",$domain->domain)) {
$contactType = "CaContact";
} else if (preg_match("/.de$/ui",$domain->domain)) {
$contactType = "DeContact";
} else if (preg_match("/.es$/ui",$domain->domain)) {
$contactType = "EsContact";
} else {
$contactType = "Contact";
}
$contactIdArray = parseRPStrArray($profile->estContactId,":x:",":");
$arrElem = $registratorId.$contactType;
$contactId = $contactIdArray[$arrElem];
if (!$contactId) {
$contactId = $directi->getDefaultContacts($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 = $directi->error;
}
}
if ($contactId) {
$invoiceOption = "NoInvoice";
if ($domain->privacy) {
$enablePrivacyProtection = "true";
} else {
$enablePrivacyProtection = "false";
}
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
$orderId = $directi->registerDomain($domain->domain, $period, $contactId, $defaultDnsServer1, $defaultDnsServer2, '', '', $customerId, $invoiceOption, $enablePrivacyProtection);
}
else {
$orderId = $directi->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' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($isOwnNS) {
if ($ns1ip) { $directi->addChildNameServer($orderId, $ns1, $ns1ip); }
if (!$directi->error and $ns2ip) { $directi->addChildNameServer($orderId, $ns2, $ns2ip); }
if (!$directi->error and $ns3ip) { $directi->addChildNameServer($orderId, $ns3, $ns3ip); }
if (!$directi->error and $ns4ip) { $directi->addChildNameServer($orderId, $ns4, $ns4ip); }
if (!$directi->error) {
if ($directi->updateNS($orderId, $ns1, $ns2, $ns3, $ns4)) {
$error = "";
} else {
$error = $directi->error;
}
}
else {
$error = $directi->error;
}
}
else {
$error = "";
}
} else {
$error = $directi->error;
}
} else if (!$error) { $error = "no contact id"; }
} else if (!$error) { $error = "no customer id"; }
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "todaynic") {
$todaynic_url = $registrator->url;
$todaynic_user = $registrator->text1;
$todaynic_password = decodePwd($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) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; }
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
$contactId=$todaynic->registerDomain($domain->domain, $period, $defaultDnsServer1, $defaultDnsServer2, '', '', $name, $company, $profile->country, "", $profile->post, $city, $address1, $telNo, $faxNo, "", $profile->email);
}
else {
$contactId=$todaynic->registerDomain($domain->domain, $period, $ns1, $ns2, $ns3, $ns4, $name, $company, $profile->country, "", $profile->post, $city, $address1, $telNo, $faxNo, "", $profile->email);
}
mconnect();
if ($contactId) {
@mysql_query("update orders_domains set todaynicContactId='$contactId[0],$contactId[1],$contactId[2],$contactId[3]',status=1,autoregby='$zone->autoreg' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($isOwnNS) {
if ($todaynic->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip)) {
$error = "";
} else {
$error = $todaynic->error;
}
}
else {
$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;
$mail_handle_subject = $registrator->tplsubj4;
$mail_handle_to = $registrator->tplto4;
$mail_handle_body = $registrator->tpl4;
$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; $prefix = "UANIC"; }
else if (preg_match("/{ripn}/ui",$mail_body)) { $nichandle = $profile->ripn; $needHandle = 1; $prefix = "RIPN"; }
else if (preg_match("/{eunic}/ui",$mail_body)) { $nichandle = $profile->eunic; $needHandle = 1; $prefix = "EUNIC"; }
else if (preg_match("/{dpnic}/ui",$mail_body)) { $nichandle = $profile->dpnic; $needHandle = 1; $prefix = "DPNIC"; }
else if (preg_match("/{epnic}/ui",$mail_body)) { $nichandle = $profile->epnic; $needHandle = 1; $prefix = "EPNIC"; }
if (!$nichandle and $needHandle) {
$hm = GetFirstActiveRegistratorByType("hostmaster");
if ($prefix == "UANIC" and $hm->id) {
$hostmaster_url = $hm->url;
$hostmaster_port = $hm->port;
$hostmaster_user = $hm->text1;
$hostmaster_password = decodePwd($hm->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);
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) {
$nichandle = $nichandle."-UANIC";
@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;
}
$hostmaster->disconnect();
}
}
else if ($mail_handle_body) {
if (!$mail_handle_to) { $mail_handle_to = $mail_to; }
$nichandle = strtoupper(generatePassword(6,0,1))."-".$prefix;
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 = "";
$orgid = "";
}
else if ($profile->org == "3") {
$person = "";
$org = $profile->firmaeng;
$orgid = $profile->edrpou;
}
$address = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$mail_handle_subject = str_replace('{nichandle}',$nichandle,$mail_handle_subject);
if ($profile->org == "1" or $profile->org == "2") {
$mail_handle_body = str_replace('{personORorg}',"person: ".$person,$mail_handle_body);
}
else if ($profile->org == "3") {
if ($orgid) {
$mail_handle_body = str_replace('{personORorg}',"organization: ".$org."norg-id: $orgid",$mail_handle_body);
} else {
$mail_handle_body = str_replace('{personORorg}',"organization: ".$org,$mail_handle_body);
}
}
$mail_handle_body = str_replace('{nichandle}',$nichandle,$mail_handle_body);
$mail_handle_body = str_replace('{person}',$person,$mail_handle_body);
$mail_handle_body = str_replace('{organization}',$org,$mail_handle_body);
$mail_handle_body = str_replace('{org-id}',$orgid,$mail_handle_body);
$mail_handle_body = str_replace('{address}',$address,$mail_handle_body);
$mail_handle_body = str_replace('{city}',$city,$mail_handle_body);
$mail_handle_body = str_replace('{country}',$profile->country,$mail_handle_body);
$mail_handle_body = str_replace('{phone}',$profile->phone,$mail_handle_body);
$mail_handle_body = str_replace('{fax}',$profile->fax,$mail_handle_body);
$mail_handle_body = str_replace('{mobile}',$profile->mobile,$mail_handle_body);
$mail_handle_body = str_replace('{email}',$profile->email,$mail_handle_body);
$mail_handle_body = str_replace('{senderemail}',$mail_from,$mail_handle_body);
$mail_handle_body = str_replace('{yyyy}',date("Y"),$mail_handle_body);
$mail_handle_body = str_replace('{mm}',date("m"),$mail_handle_body);
$mail_handle_body = str_replace('{dd}',date("d"),$mail_handle_body);
$mail_handle_body = str_replace('{hh}',date("H"),$mail_handle_body);
$mail_handle_body = str_replace('{min}',date("i"),$mail_handle_body);
$mail_handle_body = str_replace('{ss}',date("s"),$mail_handle_body);
if ($usekoi8) {
$encoding = "KOI8-R";
$mail_handle_subject = iconv("UTF-8", "KOI8-R//IGNORE", $mail_handle_subject);
$mail_handle_body = iconv("UTF-8", "KOI8-R//IGNORE", $mail_handle_body);
} else if ($usekoi8u) {
$encoding = "KOI8-U";
$mail_handle_subject = iconv("UTF-8", "KOI8-U//IGNORE", $mail_handle_subject);
$mail_handle_body = iconv("UTF-8", "KOI8-U//IGNORE", $mail_handle_body);
} else {
$encoding="WINDOWS-1251";
$mail_handle_subject = iconv("UTF-8", "WINDOWS-1251", $mail_handle_subject);
$mail_handle_body = iconv("UTF-8", "WINDOWS-1251", $mail_handle_body);
}
sendmail($mail_handle_to,'',$mail_from,$mail_handle_subject,$mail_handle_body,'','','text',$encoding);
@mysql_query("update users_profile set ".mb_strtolower($prefix)."='$nichandle' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$nichandle = $mail_nichandle;
}
}
if (!$error) {
if ($nichandle or !$needHandle) {
$nslistcode = "nserver: $ns1"; if ($ns1ip) { $nslistcode .= " $ns1ip";}
$nslistcode .= "rnnserver: $ns2"; if ($ns2ip) { $nslistcode .= " $ns2ip";}
if ($ns3) { $nslistcode .= "rnnserver: $ns3"; if ($ns3ip) { $nslistcode .= " $ns3ip";} }
if ($ns4) { $nslistcode .= "rnnserver: $ns4"; if ($ns4ip) { $nslistcode .= " $ns4ip";} }
if (preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain->domain)) {
$idna = new idna_convert();
$domain->domain = $idna->encode($domain->domain);
}
$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('{ns1}',$ns1,$mail_body);
$mail_body = str_replace('{ns1ip}',$ns1ip,$mail_body);
$mail_body = str_replace('{ns2}',$ns2,$mail_body);
$mail_body = str_replace('{ns2ip}',$ns2ip,$mail_body);
$mail_body = str_replace('{ns3}',$ns3,$mail_body);
$mail_body = str_replace('{ns3ip}',$ns3ip,$mail_body);
$mail_body = str_replace('{ns4}',$ns4,$mail_body);
$mail_body = str_replace('{ns4ip}',$ns4ip,$mail_body);
$mail_body = str_replace('{uanic}',$nichandle,$mail_body);
$mail_body = str_replace('{eunic}',$nichandle,$mail_body);
$mail_body = str_replace('{dpnic}',$nichandle,$mail_body);
$mail_body = str_replace('{epnic}',$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//IGNORE", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-R//IGNORE", $mail_body);
} else if ($usekoi8u) {
$encoding = "KOI8-U";
$mail_subject = iconv("UTF-8", "KOI8-U//IGNORE", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-U//IGNORE", $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,'','','text',$encoding);
mconnect();
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='$ns1',ns2='$ns2',ns3='$ns3',ns4='$ns4',ns1ip='$ns1ip',ns2ip='$ns2ip',ns3ip='$ns3ip',ns4ip='$ns4ip' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
}
else { $error = "Авторегистрация домена не возможна, т.к. у клиента не заполнено поле UANIC/EUNIC/RIPN/DPNIC/EPNIC и не указан Nic-handle по умолчанию для $registrator->name"; }
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны все необходимые настройки для $registrator->name"; }
} else if ($registrator->type == "started") {
$started_url = $registrator->url;
$started_user = $registrator->text1;
$started_password = decodePwd($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 = mb_split(" ",$profile->phone); $phone = $phone[1]." ".$phone[2];
$fax = mb_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,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
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='".encodePwd($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 = decodePwd($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 = mb_split(" ",$profile->phone); $phone = $phone[0]."-".$phone[1]."-".$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0]."-".$fax[1]."-".$fax[2]; } else { $fax = $phone; }
if ($domain->privacy) {
$protection = "A";
} else {
$protection = "B";
}
$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,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$manager_email);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' 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 = decodePwd($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 = mb_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]) {
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
$result = $ukrnames->registerDomain($domain->domain,$defaultDnsServer1,$defaultDnsServer2,'','',$contactId[0],$contactId[1],$contactId[2],$contactId[3],$pw);
}
else {
$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',panel_pwd='".encodePwd($pw)."' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($isOwnNS) {
if ($ns1ip) { $ukrnames->createNS($ns1, $ns1ip, $zone->zone); }
if (!$ukrnames->error and $ns2ip) { $ukrnames->createNS($ns2, $ns2ip, $zone->zone); }
if (!$ukrnames->error and $ns3ip) { $ukrnames->createNS($ns3, $ns3ip, $zone->zone); }
if (!$ukrnames->error and $ns4ip) { $ukrnames->createNS($ns4, $ns4ip, $zone->zone); }
if (!$ukrnames->error) {
if ($ukrnames->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4)) {
$error = "";
} else {
$error = $ukrnames->error;
}
}
else {
$error = $ukrnames->error;
}
}
else {
$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 = decodePwd($registrator->text2);
$r01_handle = $registrator->select1;
if ($r01_url and $r01_port and $r01_user and $r01_password and $r01_handle) {
$r01 = new R01;
$r01->init($r01_url,$r01_port,$r01_user,$r01_password);
$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;
if ($domain->privacy) {
$isprotected = 1;
} else {
$isprotected = 0;
}
if ($profile->country == "RU") { $isresident = 1; } else { $isresident = 0; }
if ($profile->org == "1" or $profile->org == "2") {
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$nic_hdl = "RPL_".mt_rand(1000000,9999999)."_".$localContactUser->id."_".$profile->id."-".$r01_handle;
} else {
$nic_hdl = "RPL_".mt_rand(1000000,9999999)."_".$user->id."_".$profile->id."-".$r01_handle;
}
$passport_date = mb_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 = mb_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") {
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$nic_hdl = "RPL_".$localContactUser->id."_".$profile->id."-ORG"."-".$r01_handle;
} else {
$nic_hdl = "RPL_".$user->id."_".$profile->id."-ORG"."-".$r01_handle;
}
$nicHandle=$r01->createContactOrg($nic_hdl, $profile->firma, $profile->firmaeng, $profile->inn, $profile->kpp, $profile->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,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$nicHandle,'');
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' 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 = decodePwd($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;
if ($domain->privacy) {
$data_publishing_approval = false;
} else {
$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, $ns1ip, $ns2ip, $ns3ip, $ns4ip, $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' 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 if ($registrator->type == "rrpproxy") {
$rrpproxy_url = $registrator->url;
$rrpproxy_user = $registrator->text1;
$rrpproxy_password = decodePwd($registrator->text2);
if ($rrpproxy_url and $rrpproxy_user and $rrpproxy_password) {
$rrpproxy = new RRPPROXY;
$rrpproxy->init($rrpproxy_url,$rrpproxy_user,$rrpproxy_password);
$contactId = $profile->rrpproxyContactId;
if (!$contactId) {
$Firstname = GotoTranslit($profile->name);
$Lastname = GotoTranslit($profile->surname);
$Middlename = GotoTranslit($profile->otchestvo);
if ($profile->org == "3") { $Organization = $profile->firmaeng; }
$Street = GotoTranslit($profile->street);
$City = GotoTranslit($profile->city);
$State = GotoTranslit($profile->oblast);
$contactId=$rrpproxy->createContact($Firstname,$Middlename,$Lastname,$Organization,$Street,$City,$State,$profile->post,$profile->country,$profile->phone,$profile->fax,$profile->email);
mconnect();
if ($contactId) {
@mysql_query("update users_profile set rrpproxyContactId='$contactId' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $rrpproxy->error;
}
}
if ($contactId) {
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
$result=$rrpproxy->regDomain($domain->domain,$period,$contactId,$defaultDnsServer1,$defaultDnsServer2,'','',$zone->promo,$profile->country,$profile->email);
}
else {
$result=$rrpproxy->regDomain($domain->domain,$period,$contactId,$ns1,$ns2,$ns3,$ns4,$zone->promo,$profile->country,$profile->email);
}
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($isOwnNS) {
if ($ns1ip) { $rrpproxy->AddNameserver($ns1, $ns1ip); }
if (!$rrpproxy->error and $ns2ip) { $rrpproxy->AddNameserver($ns2, $ns2ip); }
if (!$rrpproxy->error and $ns3ip) { $rrpproxy->AddNameserver($ns3, $ns3ip); }
if (!$rrpproxy->error and $ns4ip) { $rrpproxy->AddNameserver($ns4, $ns4ip); }
if (!$rrpproxy->error) {
if ($rrpproxy->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4)) {
$error = "";
} else {
$error = $rrpproxy->error;
}
}
else {
$error = $rrpproxy->error;
}
}
else {
$error = "";
}
} else {
$error = $rrpproxy->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "ppua") {
$ppua_url = $registrator->url;
$ppua_port = $registrator->port;
$ppua_user = $registrator->text1;
$ppua_password = decodePwd($registrator->text2);
$ppua_log = $registrator->check1;
if ($ppua_url and $ppua_port and $ppua_user and $ppua_password) {
$pw = generatePassword(8,0);
$ppua = new PPUA;
$ppua->init($ppua_url,$ppua_port,$ppua_user,$ppua_password,$ppua_log);
$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);
if (mb_strtolower($zone->zone) == "pp.ua") {
$mobile = mb_split(" ",$profile->mobile); $mobile = $mobile[0].".".$mobile[1].$mobile[2];
} else {
$mobile = mb_split(" ",$profile->phone); $mobile = $mobile[0].".".$mobile[1].$mobile[2];
}
if (!$domain->ppuaContactId) {
$contactId=$ppua->createContact($name,$org,$street,$city,$oblast,$profile->post,$profile->country,$mobile,$profile->email,$pw);
} else {
$contactId=$domain->ppuaContactId;
}
mconnect();
if ($contactId and !$domain->ppuaContactId) {
@mysql_query("update orders_domains set ppuaContactId='".$contactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$domain->ppuaContactId) {
$error = $ppua->error;
}
if ($contactId) {
$result=$ppua->registerDomain($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$contactId,$pw);
mconnect();
if ($result) {
if ($result == "ok") { $registrarDomainStatus = 1; } else if ($result == "pending") { $registrarDomainStatus = 3;}
@mysql_query("update orders_domains set status=$registrarDomainStatus,autoregby='$zone->autoreg',panel_pwd='".encodePwd($pw)."' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $ppua->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "websitews") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
$pw = generatePassword(8,0);
$rgstr = new WEBSITEWS;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if (!$domain->websitewsContactId) {
$contactId = $rgstr->createContact($name, $org, $street, $city, $oblast, $profile->post, $profile->country, $phone, $profile->email, $pw);
} else {
$contactId = $domain->websitewsContactId;
}
mconnect();
if ($contactId and !$domain->websitewsContactId) {
@mysql_query("update orders_domains set websitewsContactId='".$contactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$domain->websitewsContactId) {
$error = $rgstr->error;
}
if ($contactId) {
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
$result = $rgstr->registerDomain($domain->domain, $period, $defaultDnsServer1, $defaultDnsServer2, '', '', $contactId, $pw);
}
else {
$result = $rgstr->registerDomain($domain->domain, $period, $ns1, $ns2, $ns3, $ns4, $contactId, $pw);
}
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',panel_pwd='".encodePwd($pw)."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($isOwnNS) {
if ($rgstr->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip)) {
$error = "";
} else {
$error = $rgstr->error;
}
}
else {
$error = "";
}
} else {
$error = $rgstr->error;
}
}
$rgstr->disconnect();
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "namecheap") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new NAMECHEAP;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log, $ip);
if ($domain->privacy) { $AddFreeWhoisguard = 1; } else { $AddFreeWhoisguard = 0; }
$PromotionCode = $zone->promo;
if ($profile->org == "3") { $OrganizationName = $profile->firmaeng;}
$FirstName = GotoTranslit($profile->name);
$LastName = GotoTranslit($profile->surname);
$Address1 = GotoTranslit($profile->street);
$City = GotoTranslit($profile->city);
if ($profile->oblast) { $StateProvince = GotoTranslit($profile->oblast); } else { $StateProvince = "NA"; }
$PostalCode = $profile->post;
$Country = $profile->country;
$Phone = mb_split(" ",$profile->phone); $Phone = $Phone[0].".".$Phone[1].$Phone[2];
if ($profile->fax) { $Fax = mb_split(" ",$profile->fax); $Fax = $Fax[0].".".$Fax[1].$Fax[2]; }
$Email = $profile->email;
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
$result = $rgstr->registerDomain($domain->domain, $period, $defaultDnsServer1, $defaultDnsServer2, '', '', $AddFreeWhoisguard, $PromotionCode, $OrganizationName, $FirstName, $LastName, $Address1, $City, $StateProvince, $PostalCode, $Country, $Phone, $Fax, $Email);
}
else {
$result = $rgstr->registerDomain($domain->domain, $period, $ns1, $ns2, $ns3, $ns4, $AddFreeWhoisguard, $PromotionCode, $OrganizationName, $FirstName, $LastName, $Address1, $City, $StateProvince, $PostalCode, $Country, $Phone, $Fax, $Email);
}
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($isOwnNS) {
if ($rgstr->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip)) {
$error = "";
} else {
$error = $rgstr->error;
}
}
else {
$error = "";
}
} else {
$error = $rgstr->error;
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "pskz") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new PSKZ;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log);
$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);
if (!$domain->pskzContactId) {
$contactId = $rgstr->createContact($name, $org, $profile->country, $oblast, $profile->post, $city, $street, $profile->email, $profile->phone, $profile->fax);
} else {
$contactId = $domain->pskzContactId;
}
mconnect();
if ($contactId and !$domain->pskzContactId) {
@mysql_query("update orders_domains set pskzContactId='".$contactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$domain->pskzContactId) {
$error = $rgstr->error;
}
if ($contactId) {
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
$result = $rgstr->registerDomain($domain->domain, $contactId, $defaultDnsServer1, $defaultDnsServer2, "", "", $period);
}
else {
$result = $rgstr->registerDomain($domain->domain, $contactId, $ns1, $ns2, $ns3, $ns4, $period);
}
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($isOwnNS) {
if ($rgstr->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip)) {
$error = "";
} else {
$error = $rgstr->error;
}
}
else {
$error = "";
}
} else {
$error = $rgstr->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "dotfm") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
$pw = generatePassword(8,0);
$rgstr = new DOTFM;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if (!$domain->dotfmContactId) {
$contactId = $rgstr->createContact($name, $org, $street, $city, $oblast, $profile->post, $profile->country, $phone, $profile->email, $pw);
} else {
$contactId = $domain->dotfmContactId;
}
mconnect();
if ($contactId and !$domain->dotfmContactId) {
@mysql_query("update orders_domains set dotfmContactId='".$contactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$domain->dotfmContactId) {
$error = $rgstr->error;
}
if ($contactId) {
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
$result = $rgstr->registerDomain($domain->domain, $period, $defaultDnsServer1, $defaultDnsServer2, '', '', $contactId, $pw);
}
else {
$result = $rgstr->registerDomain($domain->domain, $period, $ns1, $ns2, $ns3, $ns4, $contactId, $pw);
}
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',panel_pwd='".encodePwd($pw)."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($isOwnNS) {
if ($rgstr->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip)) {
$rgstr->disconnect();
$error = "";
} else {
$error = $rgstr->error;
}
}
else {
$rgstr->disconnect();
$error = "";
}
} else {
$error = $rgstr->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "niclv") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
$pw = generatePassword(8,0);
$rgstr = new NICLV;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; } else { $fax = $phone; }
if (!$domain->niclvContactId) {
$contactId = $rgstr->createContact($name, $org, $street, $city, $oblast, $profile->post, $profile->country, $phone, $fax, $profile->email, $pw);
} else {
$contactId = $domain->niclvContactId;
}
mconnect();
if ($contactId and !$domain->niclvContactId) {
@mysql_query("update orders_domains set niclvContactId='".$contactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$domain->niclvContactId) {
$error = $rgstr->error;
}
if ($contactId) {
$result = $rgstr->registerDomain($domain->domain, $period, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip, $contactId, $pw);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',panel_pwd='".encodePwd($pw)."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $rgstr->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "cnic") {
$cnic_url = $registrator->url;
$cnic_user = $registrator->text1;
$cnic_password = decodePwd($registrator->text2);
$cnic_registrar = $registrator->text3;
if ($cnic_url and $cnic_user and $cnic_password and $cnic_registrar) {
$cnic = new CNIC;
$cnic->init($cnic_url,$cnic_user,$cnic_password,$cnic_registrar);
if (!$domain->cnicHandleId) {
$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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; }
if ($domain->privacy) {
$visible = 0;
} else {
$visible = 1;
}
$cnicHandleId = $cnic->createHandle($name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$fax,$profile->email,$visible);
} else {
$cnicHandleId = $domain->cnicHandleId;
}
mconnect();
if ($cnicHandleId and !$domain->cnicHandleId) {
@mysql_query("update orders_domains set cnicHandleId='".$cnicHandleId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$domain->cnicHandleId) {
$error = $cnic->error;
}
if ($cnicHandleId) {
$result=$cnic->registerDomain($domain->domain,$period,$cnicHandleId,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $cnic->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин, пароль или название регистратора для $registrator->name"; }
}
else if ($registrator->type == "gfx") {
$gfx_url = $registrator->url;
$gfx_user = $registrator->text1;
$gfx_password = decodePwd($registrator->text2);
$gfx_registrar = $registrator->text3;
if ($gfx_url and $gfx_user and $gfx_password) {
$gfx = new GFX;
$gfx->init($gfx_url,$gfx_user,$gfx_password,$gfx_registrar);
if (!$domain->gfxContactId) {
$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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; }
$gfxContactId = $gfx->contact_add($name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$fax,$profile->email);
} else {
$gfxContactId = $domain->gfxContactId;
}
mconnect();
if ($gfxContactId and !$domain->gfxContactId) {
@mysql_query("update orders_domains set gfxContactId='".$gfxContactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$domain->gfxContactId) {
$error = $gfx->error;
}
if ($gfxContactId) {
$gfxDomainId = $gfx->register_domain($domainWithoutZone,$zone->zone,$period,$gfxContactId,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
mconnect();
if ($gfxDomainId) {
@mysql_query("update orders_domains set gfxDomainId='".$gfxDomainId."',status=1,autoregby='$zone->autoreg' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $gfx->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "internetbs") {
$internetbs_url = $registrator->url;
$internetbs_user = $registrator->text1;
$internetbs_password = decodePwd($registrator->text2);
if ($internetbs_url and $internetbs_user and $internetbs_password) {
$internetbs = new INTERNETBS;
$internetbs->init($internetbs_url,$internetbs_user,$internetbs_password);
$name = GotoTranslit($profile->name);
$surname = GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng;}
$street = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
$phone = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; }
if ($domain->privacy) { $privateWhois = "FULL"; }
$result = $internetbs->domain_create($domain->domain,$zone->zone,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$zone->promo,$name,$surname,$org,$profile->country,$oblast,$city,$profile->email,$street,$profile->post,$phone,$fax,$profile->birthday,$ip,$privateWhois);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $internetbs->error;
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "rootpanel") {
$rp_url = $registrator->url;
$rp_user = $registrator->text1;
$rp_password = decodePwd($registrator->text2);
if ($rp_url and $rp_user and $rp_password) {
$rp = new ROOTPANELAPI;
$rp->init($rp_url,$rp_user,$rp_password);
$profileIdArray = parseRPStrArray($profile->rootpanelProfileId,":x:",":");
$profileId = $profileIdArray[$registratorId];
if (!$profileId) {
$profileId = $rp->createProfile($profile->org, $profile->surname, $profile->name, $profile->otchestvo, $profile->firma, $profile->firmaeng, $profile->country, $profile->oblast, $profile->post, $profile->city, $profile->street, $profile->komu, $profile->address_org, $profile->phone, $profile->mobile, $profile->fax, $profile->email, $profile->pasport_seriya, $profile->pasport_by, myDate($profile->pasport_date), myDate($profile->birthday), $profile->inn, $profile->kpp, $profile->okonh, $profile->okpo, $profile->bank, $profile->bank_schet, $profile->bank_bik, $profile->edrpou, $profile->socstrahnumber, $profile->ogrn, $profile->ogrn_by, myDate($profile->ogrn_date), $profile->icq, $profile->skype, $profile->ripe, $profile->ripn, $profile->uanic, $profile->dpnic, $profile->epnic, $profile->eunic);
mconnect();
if ($profileId) {
$profileIdArray[$registratorId] = $profileId;
$profileIdString = parseRPArrayStr($profileIdArray,":x:",":");
@mysql_query("update users_profile set rootpanelProfileId='$profileIdString' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $rp->error;
}
}
if ($profileId) {
$result = $rp->registerDomain($domain->domain,$zone->registratorId,$period,$profileId,0,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $rp->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "epag") {
$epag_url = $registrator->url;
$epag_port = $registrator->port;
$epag_user = $registrator->text1;
$epag_password = decodePwd($registrator->text2);
$epag_customerid = $registrator->text3;
if ($epag_url and $epag_port and $epag_user and $epag_password and $epag_customerid) {
$nichandle = $profile->epnic;
$epag = new EPAG;
$epag->init($epag_url,$epag_port,$epag_user,$epag_password,$epag_customerid);
if (!$nichandle) {
$name = GotoTranslit($profile->name)." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng; $type = "Org";} else if ($profile->firma) { $company = GotoTranslit($profile->firma); $type = "Org"; } else { $type = "Person"; }
$street = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
$phone = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; } else { $fax = $phone; }
$nichandle = $epag->createContact($type,$name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$fax,$profile->email);
if ($nichandle) {
mconnect();
@mysql_query("update users_profile set epnic='$nichandle' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $epag->error;
}
}
if ($nichandle) {
$result = $epag->registerDomain($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$nichandle);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = $epag->error;
} else {
$error = $epag->error;
}
} else {
$error = $epag->error;
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, API Port, логин, пароль или customerid для $registrator->name"; }
}
else if ($registrator->type == "subreg") {
$subreg_url = $registrator->url;
$subreg_user = $registrator->text1;
$subreg_password = decodePwd($registrator->text2);
$subreg_log = $registrator->check1;
if ($subreg_url and $subreg_user and $subreg_password) {
$subreg = new SUBREG;
$subreg->init($subreg_url,$subreg_user,$subreg_password,$subreg_log);
$subregContactId = $domain->subregContactId;
if (!$subregContactId) {
$name = GotoTranslit($profile->name);
$surname = GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng;}
$street = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$pc = $profile->post;
$sp = GotoTranslit($profile->oblast);
$cc = $profile->country;
$phone = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; }
$email = $profile->email;
$subregContactId = $subreg->createContact($name, $surname, $org, $street, $city, $pc, $sp, $cc, $phone, $fax, $email);
if ($subregContactId) {
mconnect();
@mysql_query("update orders_domains set subregContactId='".$subregContactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $subreg->error;
}
}
if ($subregContactId) {
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
$result = $subreg->registerDomain($domain->domain, $period, $subregContactId, $defaultDnsServer1, $defaultDnsServer2, '', '');
}
else {
$result = $subreg->registerDomain($domain->domain, $period, $subregContactId, $ns1, $ns2, $ns3, $ns4);
}
mconnect();
if ($result) {
$registrarDomainStatus = 3;
@mysql_query("update orders_domains set status='$registrarDomainStatus',autoregby='$zone->autoreg' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $subreg->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин, пароль или название регистратора для $registrator->name"; }
}
else { $error = "Авторегистрация домена не возможна, т.к. $registrator->type - неизвестный тип регистратора"; }
}
if (!$error and $registrator->type != "started" and $registrarDomainStatus != "3") {
$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: ".decodePwd($domain->panel_pwd)."rnrn",$template);
} else {
$template = str_replace('{panel}',"",$template);
}
WriteMailLog($subject,$template,$user->id);
sendmail($user->email,$company_name,$manager_email,$subject,$template,'','',$tpl[type]);
sendmail($user->email2,$company_name,$manager_email,$subject,$template,'','',$tpl[type]);
}
}
} else { $error = "Не удалось получить днс-сервера для домена. Возможно из-за ошибки при создании аккаунта."; }
} else { $error = "Профайл не проверен администрацией."; }
} else { $error = "Профайл не заполнен всеми нужными данными. $GLOBALerror"; }
} else { $error = "Пользователь ID #".$domain->uid." не найден."; }
} else { $error = "Регистратор $registrator->name не активен."; }
} else { $error = "Авторегистрация доменов для доменной зоны $zone->zone отключена."; }
} else { $error = "Не найдена доменная зона."; }
} else { $error = "Не найден заказ на домен ID #$domain_id."; }
$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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function transferDomain($domain_id, $period, $sendErrorEmail = 1) {
global $GLOBALerror, $isAPI, $full_home_path, $onlinenicDomainTypes, $nicruService, $nicruTemplate, $startedRegion, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$domainWithoutZone = mb_split(".",$domain->domain); $domainWithoutZone = $domainWithoutZone[0];
$domain->transferAuth = htmlDecode($domain->transferAuth);
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($zone->autoreg and $zone->transferAllow) {
$registrator = GetRegistratorById($zone->autoreg);
if ($registrator->active) {
$registratorId = $registrator->id;
$user = GetUserById($domain->uid);
if ($user->id) {
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$isR = 1; $chkProfile = "max";
} else {
$isD = 1;
$chkProfile = GetSetting("checkprofiletype");
if (mb_strtolower($zone->zone) == "pp.ua") { $rF[] = "mobile"; }
}
if (checkProfile($chkProfile, $user->id, $domain->profileId, $rF)) {
if (checkProfileByAdmin($user->id, $domain->profileId)) {
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$profile = GetUserProfileByUserId($localContactUser->id, $zone->localContact);
} else {
$profile = GetUserProfileByUserId($user->id, $domain->profileId);
}
if (!$domain->privacy and $zone->privacy and $zone->privacy_required and !($zone->privacy == "person" and $profile->org == "3")) {
$domain->privacy = 1;
@mysql_query("update orders_domains set privacy=1 where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
if ($registrator->type != "started" and $registrator->type != "r01" and $registrator->type != "rootpanel") {
$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 and $domain->defaultNSFlag and $zone->enableDefaultNS) {
if ($zone->enableCreateZone) {
if (createDomainZoneAtServer($domain_id, $ns1, $ns2, $ns3, $ns4, $sendErrorEmail)) {
$error = "";
} else {
$error = $GLOBALerror;
}
}
}
$defaultDnsServer1 = GetSetting("defaultDnsServer1");
$defaultDnsServer2 = GetSetting("defaultDnsServer2");
if (!$error) {
if ($registrator->type == "regru") {
$regru_url = $registrator->url;
$regru_user = $registrator->text1;
$regru_password = decodePwd($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 (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
if ($domain->privacy) {
$private_person_flag = "1";
} else {
$private_person_flag = "0";
}
$result=$regru->transferRuDomain($domain->domain,$period,$regru_fail_if_no_money,$regru_no_bill_notify);
} 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) = mb_split(" ", $profile->phone);
$o_phone = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) {
list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax);
$o_fax = $faxNoCc.".".$faxNo1."".$faxNo2;
}
$o_addr = GotoTranslit($profile->street);
$o_city = GotoTranslit($profile->city);
$o_state = "NA";
$result=$regru->transferEtcDomain($domain->domain,$period,$domain->transferAuth,$regru_fail_if_no_money,$regru_no_bill_notify,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$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=3,autoregby='$zone->autoreg',transfer='2' 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 == "nicru") {
$nicru_url = $registrator->url;
$nicru_user = $registrator->text1;
$nicru_password = decodePwd($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 = mb_strtolower($zone->zone);
$service = $nicruService[$zidx];
$ntemplate = $nicruTemplate[$zidx];
if ($service and $ntemplate) {
if ($domain->privacy) {
$private_person = "ON";
} else {
$private_person = "OFF";
}
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$orderId = $nicru->transferRuDomain($anketaId,$service,$ntemplate,$domain->domain);
} 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) {
$service = @preg_replace("/^domain/ui","pickup",$service);
$orderId = $nicru->transferDomain($anketaId,$contactId,$service,$ntemplate,$domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
}
}
mconnect();
if ($orderId) {
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',nicruOrderId='$orderId',transfer=2,panel_url='https://www.nic.ru/manager/',panel_user='$anketaId',panel_pwd='".encodePwd($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 == "ukrnames") {
$ukrnames_url = $registrator->url;
$ukrnames_port = $registrator->port;
$ukrnames_user = $registrator->text1;
$ukrnames_password = decodePwd($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 = mb_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->transferDomain($domain->domain,$period,$contactId[0],$contactId[1],$contactId[2],$contactId[3],$domain->transferAuth);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=3,transfer='2',autoregby='$zone->autoreg',panel_pwd='".encodePwd($pw)."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $ukrnames->error;
}
}
}
else { $error = "Трансфер домена не возможен, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "todaynic") {
$todaynic_url = $registrator->url;
$todaynic_user = $registrator->text1;
$todaynic_password = decodePwd($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) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; }
$contactId=$todaynic->transferDomain($domain->domain, $period, $ns1, $ns2, $ns3, $ns4, $name, $company, $profile->country, "", $profile->post, $city, $address1, $telNo, $faxNo, "", $profile->email, $domain->transferAuth);
mconnect();
if ($contactId) {
@mysql_query("update orders_domains set todaynicContactId='$contactId[0],$contactId[1],$contactId[2],$contactId[3]',status=3,transfer='2',autoregby='$zone->autoreg' 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 == "rrpproxy") {
$rrpproxy_url = $registrator->url;
$rrpproxy_user = $registrator->text1;
$rrpproxy_password = decodePwd($registrator->text2);
if ($rrpproxy_url and $rrpproxy_user and $rrpproxy_password) {
$rrpproxy = new RRPPROXY;
$rrpproxy->init($rrpproxy_url,$rrpproxy_user,$rrpproxy_password);
$result=$rrpproxy->transferDomain($domain->domain,$domain->transferAuth);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $rrpproxy->error;
}
}
else { $error = "Трансфер домена не возможен, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "hostmaster") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($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->transferDomain($domain->domain);
if ($result) {
mconnect();
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $hostmaster->error;
}
$hostmaster->disconnect();
mconnect();
}
else { $error = "Трансфер домена не возможен, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "hostmasterepp") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($registrator->text2);
$hostmaster_ssl = $registrator->text3;
$hostmaster_log = $registrator->check1;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTEREPP;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password,$hostmaster_ssl,$hostmaster_log);
$result = $hostmaster->transferDomain($domain->domain, $period, $domain->transferAuth);
if ($result) {
mconnect();
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $hostmaster->error;
}
$hostmaster->logout();
mconnect();
}
else { $error = "Трансфер домена не возможен, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "nicdpua") {
$nicdpua_url = $registrator->url;
$nicdpua_port = $registrator->port;
$nicdpua_user = $registrator->text1;
$nicdpua_password = decodePwd($registrator->text2);
$nicdpua_ssl = $registrator->text3;
$nicdpua_log = $registrator->check1;
if ($nicdpua_url and $nicdpua_port and $nicdpua_user and $nicdpua_password) {
$nicdpua = new NICDPUA;
$nicdpua->init($nicdpua_url,$nicdpua_port,$nicdpua_user,$nicdpua_password,$nicdpua_ssl,$nicdpua_log);
$result = $nicdpua->transferDomain($domain->domain, $period, $domain->transferAuth);
if ($result) {
mconnect();
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $nicdpua->error;
}
$nicdpua->logout();
mconnect();
}
else { $error = "Трансфер домена не возможен, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "networking4all") {
$n4all_url = $registrator->url;
$n4all_user = $registrator->text1;
$n4all_password = decodePwd($registrator->text2);
$n4all_handle = $registrator->text3;
if ($n4all_url and $n4all_user and $n4all_password and $n4all_handle) {
$n4all = new NETWORKING4ALL;
$n4all->init($n4all_url,$n4all_user,$n4all_password,$n4all_handle);
$contactId = $domain->networking4allContactId;
if (!$contactId) {
$initials = GotoTranslit(mb_substr($profile->name,0,1)).".";
$firstName = GotoTranslit($profile->name);
$middleName = GotoTranslit($profile->otchestvo);
$lastName = GotoTranslit($profile->surname);
$street = GotoTranslit($profile->street);
$postalCode = $profile->post;
$city = GotoTranslit($profile->city);
if ($profile->oblast) { $province = GotoTranslit($profile->oblast); } else { $province = $city; }
$countryCode = $profile->country;
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $phoneNumber = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNumber = $faxNoCc.".".$faxNo1."".$faxNo2; } else { $faxNumber = ""; }
if ($profile->mobile) { list($mobNoCc,$mobNo1,$mobNo2) = mb_split(" ", $profile->mobile); $mobileNumber = $mobNoCc.".".$mobNo1."".$mobNo2; } else { $mobileNumber = ""; }
$email = $profile->email;
$contactId = $n4all->createContact($initials, $firstName, $middleName, $lastName, $street, $postalCode, $city, $province, $countryCode, $phoneNumber, $faxNumber, $mobileNumber, $email);
mconnect();
if ($contactId) {
@mysql_query("update orders_domains set networking4allContactId='$contactId' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $n4all->error;
}
}
if (!$error) {
$result = $n4all->transferDomain($domain->domain, $contactId, $domain->transferAuth, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $n4all->error;
}
}
}
else { $error = "Трансфер домена не возможен, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "internetbs") {
$internetbs_url = $registrator->url;
$internetbs_user = $registrator->text1;
$internetbs_password = decodePwd($registrator->text2);
if ($internetbs_url and $internetbs_user and $internetbs_password) {
$internetbs = new INTERNETBS;
$internetbs->init($internetbs_url,$internetbs_user,$internetbs_password);
$name = GotoTranslit($profile->name);
$surname = GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng;}
$street = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
$phone = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; }
if ($domain->privacy) { $privateWhois = "FULL"; }
$result = $internetbs->domain_transfer($domain->domain,$zone->zone,$domain->transferAuth,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$zone->promo,$name,$surname,$org,$profile->country,$oblast,$city,$profile->email,$street,$profile->post,$phone,$fax,$profile->birthday,$ip,$privateWhois);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $internetbs->error;
}
}
else { $error = "Трансфер домена не возможен, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "ppua") {
$ppua_url = $registrator->url;
$ppua_port = $registrator->port;
$ppua_user = $registrator->text1;
$ppua_password = decodePwd($registrator->text2);
$ppua_log = $registrator->check1;
if ($ppua_url and $ppua_port and $ppua_user and $ppua_password) {
$pw = generatePassword(8,0);
$ppua = new PPUA;
$ppua->init($ppua_url,$ppua_port,$ppua_user,$ppua_password,$ppua_log);
$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);
if (mb_strtolower($zone->zone) == "pp.ua") {
$mobile = mb_split(" ",$profile->mobile); $mobile = $mobile[0].".".$mobile[1].$mobile[2];
} else {
$mobile = mb_split(" ",$profile->phone); $mobile = $mobile[0].".".$mobile[1].$mobile[2];
}
if (!$domain->ppuaContactId) {
$contactId=$ppua->createContact($name,$org,$street,$city,$oblast,$profile->post,$profile->country,$mobile,$profile->email,$pw);
} else {
$contactId=$domain->ppuaContactId;
}
mconnect();
if ($contactId and !$domain->ppuaContactId) {
@mysql_query("update orders_domains set ppuaContactId='".$contactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$domain->ppuaContactId) {
$error = $ppua->error;
}
if ($contactId) {
$result=$ppua->transferDomain($domain->domain,$period,$contactId,$domain->transferAuth);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',panel_pwd='".encodePwd($pw)."',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $ppua->error;
}
}
}
else { $error = "Трансфер домена не возможен, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "websitews") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
$pw = generatePassword(8,0);
$rgstr = new WEBSITEWS;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if (!$domain->websitewsContactId) {
$contactId = $rgstr->createContact($name, $org, $street, $city, $oblast, $profile->post, $profile->country, $phone, $profile->email, $pw);
} else {
$contactId = $domain->websitewsContactId;
}
mconnect();
if ($contactId and !$domain->websitewsContactId) {
@mysql_query("update orders_domains set websitewsContactId='".$contactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$domain->websitewsContactId) {
$error = $rgstr->error;
}
if ($contactId) {
$result = $rgstr->transferDomain($domain->domain, $period, $contactId, $domain->transferAuth);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',panel_pwd='".encodePwd($pw)."',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $rgstr->error;
}
}
$rgstr->disconnect();
}
else { $error = "Трансфер домена не возможен, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "namecheap") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new NAMECHEAP;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log, $ip);
$result = $rgstr->transferDomain($domain->domain, $period, $domain->transferAuth, $zone->promo);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = "Трансфер домена не возможен, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "pskz") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new PSKZ;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log);
$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);
if (!$domain->pskzContactId) {
$contactId = $rgstr->createContact($name, $org, $profile->country, $oblast, $profile->post, $city, $street, $profile->email, $profile->phone, $profile->fax);
} else {
$contactId = $domain->pskzContactId;
}
mconnect();
if ($contactId and !$domain->pskzContactId) {
@mysql_query("update orders_domains set pskzContactId='".$contactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$domain->pskzContactId) {
$error = $rgstr->error;
}
if ($contactId) {
$result = $rgstr->transferDomain($domain->domain, $contactId, $domain->transferAuth);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $rgstr->error;
}
}
}
else { $error = "Трансфер домена не возможен, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "dotfm") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
$pw = generatePassword(8,0);
$rgstr = new DOTFM;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if (!$domain->dotfmContactId) {
$contactId = $rgstr->createContact($name, $org, $street, $city, $oblast, $profile->post, $profile->country, $phone, $profile->email, $pw);
} else {
$contactId = $domain->dotfmContactId;
}
mconnect();
if ($contactId and !$domain->dotfmContactId) {
@mysql_query("update orders_domains set dotfmContactId='".$contactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$domain->dotfmContactId) {
$error = $rgstr->error;
}
if ($contactId) {
$result = $rgstr->transferDomain($domain->domain, $period, $contactId, $domain->transferAuth);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',panel_pwd='".encodePwd($pw)."',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$rgstr->disconnect();
$error = "";
} else {
$error = $rgstr->error;
}
}
}
else { $error = "Трансфер домена не возможен, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "mail") {
$mail_to = $registrator->text3;
$mail_from = $registrator->text1;
$mail_nichandle = $registrator->text4;
$mail_subject = $registrator->tplsubj5;
$mail_body = $registrator->tpl5;
$mail_handle_subject = $registrator->tplsubj4;
$mail_handle_to = $registrator->tplto4;
$mail_handle_body = $registrator->tpl4;
$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; $prefix = "UANIC"; }
else if (preg_match("/{ripn}/ui",$mail_body)) { $nichandle = $profile->ripn; $needHandle = 1; $prefix = "RIPN"; }
else if (preg_match("/{eunic}/ui",$mail_body)) { $nichandle = $profile->eunic; $needHandle = 1; $prefix = "EUNIC"; }
else if (preg_match("/{dpnic}/ui",$mail_body)) { $nichandle = $profile->dpnic; $needHandle = 1; $prefix = "DPNIC"; }
else if (preg_match("/{epnic}/ui",$mail_body)) { $nichandle = $profile->epnic; $needHandle = 1; $prefix = "EPNIC"; }
if (!$nichandle and $needHandle) {
$hm = GetFirstActiveRegistratorByType("hostmaster");
if ($prefix == "UANIC" and $hm->id) {
$hostmaster_url = $hm->url;
$hostmaster_port = $hm->port;
$hostmaster_user = $hm->text1;
$hostmaster_password = decodePwd($hm->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);
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) {
$nichandle = $nichandle."-UANIC";
@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;
}
$hostmaster->disconnect();
}
}
else if ($mail_handle_body) {
if (!$mail_handle_to) { $mail_handle_to = $mail_to; }
$nichandle = strtoupper(generatePassword(6,0,1))."-".$prefix;
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 = "";
$orgid = "";
}
else if ($profile->org == "3") {
$person = "";
$org = $profile->firmaeng;
$orgid = $profile->edrpou;
}
$address = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$mail_handle_subject = str_replace('{nichandle}',$nichandle,$mail_handle_subject);
if ($profile->org == "1" or $profile->org == "2") {
$mail_handle_body = str_replace('{personORorg}',"person: ".$person,$mail_handle_body);
}
else if ($profile->org == "3") {
if ($orgid) {
$mail_handle_body = str_replace('{personORorg}',"organization: ".$org."norg-id: $orgid",$mail_handle_body);
} else {
$mail_handle_body = str_replace('{personORorg}',"organization: ".$org,$mail_handle_body);
}
}
$mail_handle_body = str_replace('{nichandle}',$nichandle,$mail_handle_body);
$mail_handle_body = str_replace('{person}',$person,$mail_handle_body);
$mail_handle_body = str_replace('{organization}',$org,$mail_handle_body);
$mail_handle_body = str_replace('{org-id}',$orgid,$mail_handle_body);
$mail_handle_body = str_replace('{address}',$address,$mail_handle_body);
$mail_handle_body = str_replace('{city}',$city,$mail_handle_body);
$mail_handle_body = str_replace('{country}',$profile->country,$mail_handle_body);
$mail_handle_body = str_replace('{phone}',$profile->phone,$mail_handle_body);
$mail_handle_body = str_replace('{fax}',$profile->fax,$mail_handle_body);
$mail_handle_body = str_replace('{mobile}',$profile->mobile,$mail_handle_body);
$mail_handle_body = str_replace('{email}',$profile->email,$mail_handle_body);
$mail_handle_body = str_replace('{senderemail}',$mail_from,$mail_handle_body);
$mail_handle_body = str_replace('{yyyy}',date("Y"),$mail_handle_body);
$mail_handle_body = str_replace('{mm}',date("m"),$mail_handle_body);
$mail_handle_body = str_replace('{dd}',date("d"),$mail_handle_body);
$mail_handle_body = str_replace('{hh}',date("H"),$mail_handle_body);
$mail_handle_body = str_replace('{min}',date("i"),$mail_handle_body);
$mail_handle_body = str_replace('{ss}',date("s"),$mail_handle_body);
if ($usekoi8) {
$encoding = "KOI8-R";
$mail_handle_subject = iconv("UTF-8", "KOI8-R//IGNORE", $mail_handle_subject);
$mail_handle_body = iconv("UTF-8", "KOI8-R//IGNORE", $mail_handle_body);
} else if ($usekoi8u) {
$encoding = "KOI8-U";
$mail_handle_subject = iconv("UTF-8", "KOI8-U//IGNORE", $mail_handle_subject);
$mail_handle_body = iconv("UTF-8", "KOI8-U//IGNORE", $mail_handle_body);
} else {
$encoding="WINDOWS-1251";
$mail_handle_subject = iconv("UTF-8", "WINDOWS-1251", $mail_handle_subject);
$mail_handle_body = iconv("UTF-8", "WINDOWS-1251", $mail_handle_body);
}
sendmail($mail_handle_to,'',$mail_from,$mail_handle_subject,$mail_handle_body,'','','text',$encoding);
@mysql_query("update users_profile set ".mb_strtolower($prefix)."='$nichandle' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$nichandle = $mail_nichandle;
}
}
if (!$error) {
if ($nichandle or !$needHandle) {
$nslistcode = "nserver: $ns1"; if ($ns1ip) { $nslistcode .= " $ns1ip";}
$nslistcode .= "rnnserver: $ns2"; if ($ns2ip) { $nslistcode .= " $ns2ip";}
if ($ns3) { $nslistcode .= "rnnserver: $ns3"; if ($ns3ip) { $nslistcode .= " $ns3ip";} }
if ($ns4) { $nslistcode .= "rnnserver: $ns4"; if ($ns4ip) { $nslistcode .= " $ns4ip";} }
if (preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain->domain)) {
$idna = new idna_convert();
$domain->domain = $idna->encode($domain->domain);
}
$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('{ns1}',$ns1,$mail_body);
$mail_body = str_replace('{ns1ip}',$ns1ip,$mail_body);
$mail_body = str_replace('{ns2}',$ns2,$mail_body);
$mail_body = str_replace('{ns2ip}',$ns2ip,$mail_body);
$mail_body = str_replace('{ns3}',$ns3,$mail_body);
$mail_body = str_replace('{ns3ip}',$ns3ip,$mail_body);
$mail_body = str_replace('{ns4}',$ns4,$mail_body);
$mail_body = str_replace('{ns4ip}',$ns4ip,$mail_body);
$mail_body = str_replace('{uanic}',$nichandle,$mail_body);
$mail_body = str_replace('{eunic}',$nichandle,$mail_body);
$mail_body = str_replace('{dpnic}',$nichandle,$mail_body);
$mail_body = str_replace('{epnic}',$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);
$mail_body = str_replace('{authcode}',$domain->transferAuth,$mail_body);
if ($usekoi8) {
$encoding = "KOI8-R";
$mail_subject = iconv("UTF-8", "KOI8-R//IGNORE", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-R//IGNORE", $mail_body);
} else if ($usekoi8u) {
$encoding = "KOI8-U";
$mail_subject = iconv("UTF-8", "KOI8-U//IGNORE", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-U//IGNORE", $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,'','','text',$encoding);
mconnect();
@mysql_query("update orders_domains set status=3,transfer='2',autoregby='$zone->autoreg',ns1='$ns1',ns2='$ns2',ns3='$ns3',ns4='$ns4',ns1ip='$ns1ip',ns2ip='$ns2ip',ns3ip='$ns3ip',ns4ip='$ns4ip' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
}
else { $error = "Трансфер домена не возможен, т.к. у клиента не заполнено поле UANIC/EUNIC/RIPN/DPNIC/EPNIC и не указан Nic-handle по умолчанию для $registrator->name"; }
}
}
else { $error = "Трансфер домена не возможен, т.к. не указаны все необходимые настройки для $registrator->name"; }
}
else if ($registrator->type == "internetx") {
$internetx_url = $registrator->url;
$internetx_user = $registrator->text1;
$internetx_password = decodePwd($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 = mb_split(" ",$profile->phone); $phone = $phone[0]."-".$phone[1]."-".$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0]."-".$fax[1]."-".$fax[2]; } else { $fax = $phone; }
if ($domain->privacy) {
$protection = "A";
} else {
$protection = "B";
}
$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->transferDomain($domain->domain,$domain->transferAuth,$profile->email,$contactId,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$manager_email);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=3,autoregby='$zone->autoreg',transfer='2' 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 == "directi") {
$directi_url = $registrator->url;
$directi_user = $registrator->text1;
$directi_password = decodePwd($registrator->text2);
$directi_log = $registrator->check1;
if ($directi_url and $directi_user and $directi_password) {
$directi = new DIRECTI;
$directi->init($directi_url,$directi_user,$directi_password,$directi_log);
$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);
$state = GotoTranslit($profile->oblast);
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $telNoCc = preg_replace("/+/ui","",$telNoCc); $telNo = $telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNoCc = preg_replace("/+/ui","",$faxNoCc); $faxNo = $faxNo1."".$faxNo2; }
if ($profile->mobile) { list($mobileNoCc,$mobileNo1,$mobileNo2) = mb_split(" ", $profile->mobile); $mobileNoCc = preg_replace("/+/ui","",$mobileNoCc); $mobileNo = $mobileNo1."".$mobileNo2; }
$langPref = "ru";
$customerId = $directi->signUp($profile->email, generatePassword(8,1), $name, $company, $address1, "", "", $city, $state, $profile->country, $profile->post, $telNoCc, $telNo, "", "", $faxNoCc, $faxNo, $langPref, $mobileNoCc, $mobileNo);
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 = $directi->error;
}
}
if ($customerId) {
if (preg_match("/.coop$/ui",$domain->domain)) {
$contactType = "CoopContact";
} else if (preg_match("/.uk$/ui",$domain->domain)) {
$contactType = "UkContact";
} else if (preg_match("/.eu$/ui",$domain->domain)) {
$contactType = "EuContact";
} else if (preg_match("/.cn$/ui",$domain->domain)) {
$contactType = "CnContact";
} else if (preg_match("/.co$/ui",$domain->domain)) {
$contactType = "CoContact";
} else if (preg_match("/.ca$/ui",$domain->domain)) {
$contactType = "CaContact";
} else if (preg_match("/.de$/ui",$domain->domain)) {
$contactType = "DeContact";
} else if (preg_match("/.es$/ui",$domain->domain)) {
$contactType = "EsContact";
} else {
$contactType = "Contact";
}
$contactIdArray = parseRPStrArray($profile->estContactId,":x:",":");
$arrElem = $registratorId.$contactType;
$contactId = $contactIdArray[$arrElem];
if (!$contactId) {
$contactId=$directi->getDefaultContacts($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 = $directi->error;
}
}
if ($contactId) {
$invoiceOption = "NoInvoice";
if ($domain->privacy) {
$enablePrivacyProtection = "true";
} else {
$enablePrivacyProtection = "false";
}
$orderId = $directi->transferDomain($domain->domain, $domain->transferAuth, $contactId, $ns1, $ns2, $ns3, $ns4, $customerId, $invoiceOption, $enablePrivacyProtection);
mconnect();
if ($orderId) {
@mysql_query("update orders_domains set estOrderId='$orderId',status=3,autoregby='$zone->autoreg',transfer='2' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $directi->error;
}
} else if (!$error) { $error = "no contact id"; }
} else if (!$error) { $error = "no customer id"; }
}
else { $error = "Трансфер домена не возможен, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "epag") {
$epag_url = $registrator->url;
$epag_port = $registrator->port;
$epag_user = $registrator->text1;
$epag_password = decodePwd($registrator->text2);
$epag_customerid = $registrator->text3;
if ($epag_url and $epag_port and $epag_user and $epag_password and $epag_customerid) {
$nichandle = $profile->epnic;
$epag = new EPAG;
$epag->init($epag_url,$epag_port,$epag_user,$epag_password,$epag_customerid);
if (!$nichandle) {
$name = GotoTranslit($profile->name)." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng; $type = "Org";} else { $type = "Person"; }
$street = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
$phone = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; } else { $fax = $phone; }
$nichandle = $epag->createContact($type,$name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$fax,$profile->email);
if ($nichandle) {
mconnect();
@mysql_query("update users_profile set epnic='$nichandle' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $epag->error;
}
}
if ($nichandle) {
$result = $epag->transferDomain($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$nichandle,$domain->transferAuth);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status='3',transfer='2',autoregby='$zone->autoreg' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = $epag->error;
} else {
$error = $epag->error;
}
} else {
$error = $epag->error;
}
}
else { $error = "Трансфер домена не возможен, т.к. не указаны API URL, API Port, логин, пароль или customerid для $registrator->name"; }
}
else if ($registrator->type == "subreg") {
$subreg_url = $registrator->url;
$subreg_user = $registrator->text1;
$subreg_password = decodePwd($registrator->text2);
$subreg_log = $registrator->check1;
if ($subreg_url and $subreg_user and $subreg_password) {
$subreg = new SUBREG;
$subreg->init($subreg_url,$subreg_user,$subreg_password,$subreg_log);
$subregContactId = $domain->subregContactId;
if (!$subregContactId) {
$name = GotoTranslit($profile->name);
$surname = GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng;}
$street = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$pc = $profile->post;
$sp = GotoTranslit($profile->oblast);
$cc = $profile->country;
$phone = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; }
$email = $profile->email;
$subregContactId = $subreg->createContact($name, $surname, $org, $street, $city, $pc, $sp, $cc, $phone, $fax, $email);
if ($subregContactId) {
mconnect();
@mysql_query("update orders_domains set subregContactId='".$subregContactId."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $subreg->error;
}
}
if ($subregContactId) {
if ($ns1ip or $ns2ip or $ns3ip or $ns4ip) {
$isOwnNS = 1;
$result = $subreg->transferDomain($domain->domain, $subregContactId, $defaultDnsServer1, $defaultDnsServer2, '', '', $domain->transferAuth);
}
else {
$result = $subreg->transferDomain($domain->domain, $subregContactId, $ns1, $ns2, $ns3, $ns4, $domain->transferAuth);
}
mconnect();
if ($result) {
@mysql_query("update orders_domains set status='3',autoregby='$zone->autoreg',transfer='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $subreg->error;
}
}
}
else { $error = "Трансфер домена не возможен, т.к. не указаны API URL, логин, пароль или название регистратора для $registrator->name"; }
}
# else if ($registrator->type == "webnames") {
# else if ($registrator->type == "naunet") {
# else if ($registrator->type == "freehost") {
# else if ($registrator->type == "onlinenic") {
# else if ($registrator->type == "todaynic") {
# else if ($registrator->type == "started") {
# else if ($registrator->type == "r01") {
# else if ($registrator->type == "ficora") {
# else if ($registrator->type == "cnic") {
# else if ($registrator->type == "gfx") {
# else if ($registrator->type == "rootpanel") {
else { $error = "Трансфер домена не возможен, т.к. биллинг не поддерживает трансфер доменов для регистратора $registrator->type"; }
}
# if (!$error and $registrator->type != "started") {
# $domain = GetDomainById($domain_id);
#
# $tpl=GetTpl('email_touser_domain_transfer', $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: ".decodePwd($domain->panel_pwd)."rnrn",$template);
# } else {
# $template = str_replace('{panel}',"",$template);
# }
#
# WriteMailLog($subject,$template,$user->id);
# sendmail($user->email,$company_name,$manager_email,$subject,$template,'','',$tpl[type]);
# sendmail($user->email2,$company_name,$manager_email,$subject,$template,'','',$tpl[type]);
# }
# }
} else { $error = "Не удалось получить днс-сервера для домена. Возможно из-за ошибки при создании аккаунта."; }
} else { $error = "Профайл не проверен администрацией."; }
} else { $error = "Профайл не заполнен всеми нужными данными. $GLOBALerror"; }
} else { $error = "Пользователь ID #".$domain->uid." не найден."; }
} else { $error = "Регистратор $registrator->name не активен."; }
} else { $error = "Авторегистрация доменов либо поддержка трансфера для доменной зоны $zone->zone отключена."; }
} else { $error = "Не найдена доменная зона."; }
} else { $error = "Не найден заказ на домен ID #$domain_id."; }
$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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function renewDomain($domain_id, $period, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $onlinenicDomainTypes, $nicruService, $nicruTemplate, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($zone->autoreg) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->id) {
$user = GetUserById($domain->uid);
if ($user->id) {
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$profile = GetUserProfileByUserId($localContactUser->id, $zone->localContact);
} else {
$profile = GetUserProfileByUserId($user->id, $domain->profileId);
}
if ($registrator->type == "regru") {
$regru_url = $registrator->url;
$regru_user = $registrator->text1;
$regru_password = decodePwd($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 = decodePwd($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") {
$naunet_url = $registrator->url;
$naunet_user = $registrator->text1;
$naunet_password = decodePwd($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 if ($registrator->type == "activeby") {
$activeby_url = $registrator->url;
$activeby_password = decodePwd($registrator->text2);
$activeby_ssl = $registrator->text3;
$activeby_log = $registrator->check1;
if ($activeby_url and $activeby_ssl and $activeby_password) {
if ($domain->activebySubscriptionId) {
$activeby = new ACTIVEBY;
$activeby->init($activeby_url,$activeby_ssl,$activeby_password,$activeby_log);
$result=$activeby->renewDomain($domain->domain, $domain->activebySubscriptionId);
if ($result) {
$error = "";
} else {
$error = $activeby->error;
}
} else { $error = "Автопродление домена не возможно, т.к. не указан activebySubscriptionId."; }
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, файл сертификата или пароль для $registrator->name"; }
}
else if ($registrator->type == "nicru") {
$nicru_url = $registrator->url;
$nicru_user = $registrator->text1;
$nicru_password = decodePwd($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 = mb_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 = decodePwd($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 = decodePwd($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;
}
$hostmaster->disconnect();
}
else { $error = "Автопродление домена не возможно, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "hostmasterepp") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($registrator->text2);
$hostmaster_ssl = $registrator->text3;
$hostmaster_log = $registrator->check1;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTEREPP;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password,$hostmaster_ssl,$hostmaster_log);
$result = $hostmaster->renewDomain($domain->domain,$period);
if ($result) {
$error = "";
} else {
$error = $hostmaster->error;
}
$hostmaster->logout();
mconnect();
}
else { $error = "Автопродление домена не возможно, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "nicdpua") {
$nicdpua_url = $registrator->url;
$nicdpua_port = $registrator->port;
$nicdpua_user = $registrator->text1;
$nicdpua_password = decodePwd($registrator->text2);
$nicdpua_ssl = $registrator->text3;
$nicdpua_log = $registrator->check1;
if ($nicdpua_url and $nicdpua_port and $nicdpua_user and $nicdpua_password) {
$nicdpua = new NICDPUA;
$nicdpua->init($nicdpua_url,$nicdpua_port,$nicdpua_user,$nicdpua_password,$nicdpua_ssl,$nicdpua_log);
$result = $nicdpua->renewDomain($domain->domain,$period);
if ($result) {
$error = "";
} else {
$error = $nicdpua->error;
}
$nicdpua->logout();
mconnect();
}
else { $error = "Автопродление домена не возможно, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "hosterby") {
$hosterby_url = $registrator->url;
$hosterby_port = $registrator->port;
$hosterby_user = $registrator->text1;
$hosterby_password = decodePwd($registrator->text2);
$hosterby_log = $registrator->check1;
if ($hosterby_url and $hosterby_port and $hosterby_user and $hosterby_password) {
$hosterby = new HOSTERBY;
$hosterby->init($hosterby_url,$hosterby_port,$hosterby_user,$hosterby_password,$hosterby_log);
$result = $hosterby->renewDomain($domain->domain);
if ($result) {
$error = "";
} else {
$error = $hosterby->error;
}
$hosterby->logout();
}
else { $error = "Автопродление домена не возможно, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "onlinenic") {
$onlinenic_url = $registrator->url;
$onlinenic_port = $registrator->port;
$onlinenic_user = $registrator->text1;
$onlinenic_password = decodePwd($registrator->text2);
if ($onlinenic_url and $onlinenic_port and $onlinenic_user and $onlinenic_password) {
$zidx = mb_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") {
$directi_url = $registrator->url;
$directi_user = $registrator->text1;
$directi_password = decodePwd($registrator->text2);
$directi_log = $registrator->check1;
if ($directi_url and $directi_user and $directi_password) {
if ($domain->estOrderId) {
$directi = new DIRECTI;
$directi->init($directi_url,$directi_user,$directi_password,$directi_log);
$invoiceOption = "NoInvoice";
$result = $directi->renewDomain($domain->estOrderId, $period, $invoiceOption);
if ($result) {
$error = "";
} else {
$error = $directi->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не удалось получить OrderId для домена."; }
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "todaynic") {
$todaynic_url = $registrator->url;
$todaynic_user = $registrator->text1;
$todaynic_password = decodePwd($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) {
$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;}
else if (preg_match("/{eunic}/ui",$mail_body)) { $nichandle = $profile->eunic; $needHandle = 1;}
else if (preg_match("/{dpnic}/ui",$mail_body)) { $nichandle = $profile->dpnic; $needHandle = 1;}
else if (preg_match("/{epnic}/ui",$mail_body)) { $nichandle = $profile->epnic; $needHandle = 1;}
if (!$nichandle) { $nichandle = $mail_nichandle; }
if ($nichandle or !$needHandle) {
$ns1 = $domain->ns1; $ns2 = $domain->ns2; $ns3 = $domain->ns3; $ns4 = $domain->ns4;
$ns1ip = $domain->ns1ip; $ns2ip = $domain->ns2ip; $ns3ip = $domain->ns3ip; $ns4ip = $domain->ns4ip;
$nslistcode = "nserver: $ns1"; if ($ns1ip) { $nslistcode .= " $ns1ip";}
$nslistcode .= "rnnserver: $ns2"; if ($ns2ip) { $nslistcode .= " $ns2ip";}
if ($ns3) { $nslistcode .= "rnnserver: $ns3"; if ($ns3ip) { $nslistcode .= " $ns3ip";} }
if ($ns4) { $nslistcode .= "rnnserver: $ns4"; if ($ns4ip) { $nslistcode .= " $ns4ip";} }
if (preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain->domain)) {
$idna = new idna_convert();
$domain->domain = $idna->encode($domain->domain);
}
$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('{ns1}',$ns1,$mail_body);
$mail_body = str_replace('{ns1ip}',$ns1ip,$mail_body);
$mail_body = str_replace('{ns2}',$ns2,$mail_body);
$mail_body = str_replace('{ns2ip}',$ns2ip,$mail_body);
$mail_body = str_replace('{ns3}',$ns3,$mail_body);
$mail_body = str_replace('{ns3ip}',$ns3ip,$mail_body);
$mail_body = str_replace('{ns4}',$ns4,$mail_body);
$mail_body = str_replace('{ns4ip}',$ns4ip,$mail_body);
$mail_body = str_replace('{uanic}',$nichandle,$mail_body);
$mail_body = str_replace('{eunic}',$nichandle,$mail_body);
$mail_body = str_replace('{dpnic}',$nichandle,$mail_body);
$mail_body = str_replace('{epnic}',$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//IGNORE", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-R//IGNORE", $mail_body);
} else if ($usekoi8u) {
$encoding = "KOI8-U";
$mail_subject = iconv("UTF-8", "KOI8-U//IGNORE", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-U//IGNORE", $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,'','','text',$encoding);
$error = "";
}
else { $error = "Автопродление домена не возможно, т.к. у клиента не заполнено поле UANIC/EUNIC/RIPN/DPNIC/EPNIC и не указан Nic-handle по умолчанию для $registrator->name"; }
} else { $error = "Автопродление домена не возможно, т.к. не указаны все необходимые настройки для $registrator->name"; }
}
else if ($registrator->type == "started") {
$started_url = $registrator->url;
$started_user = $registrator->text1;
$started_password = decodePwd($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 = decodePwd($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);
$manager_email=GetSetting("manager_email");
$result = $internetx->domainCancelDelete($domain->domain,$manager_email);
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, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "ukrnames") {
$ukrnames_url = $registrator->url;
$ukrnames_port = $registrator->port;
$ukrnames_user = $registrator->text1;
$ukrnames_password = decodePwd($registrator->text2);
if ($ukrnames_url and $ukrnames_port and $ukrnames_user and $ukrnames_password) {
$expDate = mb_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 = decodePwd($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 = decodePwd($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 if ($registrator->type == "rrpproxy") {
$rrpproxy_url = $registrator->url;
$rrpproxy_user = $registrator->text1;
$rrpproxy_password = decodePwd($registrator->text2);
if ($rrpproxy_url and $rrpproxy_user and $rrpproxy_password) {
$rrpproxy = new RRPPROXY;
$rrpproxy->init($rrpproxy_url,$rrpproxy_user,$rrpproxy_password);
$result = $rrpproxy->renewDomain($domain->domain, $period, $zone->promo);
if ($result) {
$error = "";
} else {
$error = $rrpproxy->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "ppua") {
$ppua_url = $registrator->url;
$ppua_port = $registrator->port;
$ppua_user = $registrator->text1;
$ppua_password = decodePwd($registrator->text2);
$ppua_log = $registrator->check1;
if ($ppua_url and $ppua_port and $ppua_user and $ppua_password) {
$expDate = mb_split("-",$domain->todate);
$expDate[0] = $expDate[0] - 1;
$expDate = @join("-",$expDate);
$ppua = new PPUA;
$ppua->init($ppua_url,$ppua_port,$ppua_user,$ppua_password,$ppua_log);
$result=$ppua->renewDomain($domain->domain,$period,$expDate);
if ($result) {
@mysql_query("update orders_domains set ppuaSentRenew='1' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $ppua->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "websitews") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
$expDate = mb_split("-",$domain->todate);
$expDate[0] = $expDate[0] - 1;
$expDate = @join("-",$expDate);
$rgstr = new WEBSITEWS;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_password);
$result = $rgstr->renewDomain($domain->domain, $period, $expDate);
if ($result) {
$error = "";
} else {
$error = $rgstr->error;
}
$rgstr->disconnect();
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "namecheap") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new NAMECHEAP;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log, $ip);
$result = $rgstr->renewDomain($domain->domain, $period, $zone->promo);
if ($result) {
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "pskz") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new PSKZ;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log);
$result = $rgstr->renewDomain($domain->domain, $period);
if ($result) {
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "dotfm") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
$expDate = mb_split("-",$domain->todate);
$expDate[0] = $expDate[0] - 1;
$expDate = @join("-",$expDate);
$rgstr = new DOTFM;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_password);
$result = $rgstr->renewDomain($domain->domain, $period, $expDate);
if ($result) {
$rgstr->disconnect();
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "cnic") {
$cnic_url = $registrator->url;
$cnic_user = $registrator->text1;
$cnic_password = decodePwd($registrator->text2);
$cnic_registrar = $registrator->text3;
if ($cnic_url and $cnic_user and $cnic_password and $cnic_registrar) {
$cnic = new CNIC;
$cnic->init($cnic_url,$cnic_user,$cnic_password,$cnic_registrar);
$result=$cnic->renewDomain($domain->domain,$period);
if ($result) {
$error = "";
} else {
$error = $cnic->error;
}
}
}
else if ($registrator->type == "gfx") {
$gfx_url = $registrator->url;
$gfx_user = $registrator->text1;
$gfx_password = decodePwd($registrator->text2);
$gfx_registrar = $registrator->text3;
if ($gfx_url and $gfx_user and $gfx_password) {
if ($domain->gfxDomainId) {
$gfx = new GFX;
$gfx->init($gfx_url,$gfx_user,$gfx_password,$gfx_registrar);
$result=$gfx->renewdomain($domain->gfxDomainId,$period);
if ($result) {
$error = "";
} else {
$error = $gfx->error;
}
} else { $error = "Автопродление домена не возможно, т.к. не указан gfxDomainId."; }
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "internetbs") {
$internetbs_url = $registrator->url;
$internetbs_user = $registrator->text1;
$internetbs_password = decodePwd($registrator->text2);
if ($internetbs_url and $internetbs_user and $internetbs_password) {
$internetbs = new INTERNETBS;
$internetbs->init($internetbs_url,$internetbs_user,$internetbs_password);
$result=$internetbs->domain_renew($domain->domain,$period,$zone->promo);
if ($result) {
$error = "";
} else {
$error = $internetbs->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "rootpanel") {
$rp_url = $registrator->url;
$rp_user = $registrator->text1;
$rp_password = decodePwd($registrator->text2);
if ($rp_url and $rp_user and $rp_password) {
$rp = new ROOTPANELAPI;
$rp->init($rp_url,$rp_user,$rp_password);
$result=$rp->renewDomain($domain->domain,$period);
if ($result) {
$error = "";
} else {
$error = $rp->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "epag") {
$epag_url = $registrator->url;
$epag_port = $registrator->port;
$epag_user = $registrator->text1;
$epag_password = decodePwd($registrator->text2);
$epag_customerid = $registrator->text3;
if ($epag_url and $epag_port and $epag_user and $epag_password and $epag_customerid) {
if ($domain->epagExpire) {
$nichandle = $profile->epnic;
$epag = new EPAG;
$epag->init($epag_url,$epag_port,$epag_user,$epag_password,$epag_customerid);
$result = $epag->unExpire($domain->domain, $nichandle);
mconnect();
if ($result) {
@mysql_query("update orders_domains set epagExpire='0' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $epag->error;
}
}
else { $error = $epag->error; }
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, API Port, логин, пароль или customerid для $registrator->name"; }
}
else if ($registrator->type == "networking4all") {
$n4all_url = $registrator->url;
$n4all_user = $registrator->text1;
$n4all_password = decodePwd($registrator->text2);
$n4all_handle = $registrator->text3;
if ($n4all_url and $n4all_user and $n4all_password and $n4all_handle) {
if ($domain->networking4allNoAutoRenew) {
$n4all = new NETWORKING4ALL;
$n4all->init($n4all_url,$n4all_user,$n4all_password,$n4all_handle);
$result = $n4all->enableAutoRenew($domain->domain);
mconnect();
if ($result) {
@mysql_query("update orders_domains set networking4allNoAutoRenew='0' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $n4all->error;
}
}
else { $error = ""; }
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "subreg") {
$subreg_url = $registrator->url;
$subreg_user = $registrator->text1;
$subreg_password = decodePwd($registrator->text2);
$subreg_log = $registrator->check1;
if ($subreg_url and $subreg_user and $subreg_password) {
$subreg = new SUBREG;
$subreg->init($subreg_url,$subreg_user,$subreg_password,$subreg_log);
$result = $subreg->renewDomain($domain->domain, $period);
if ($result) {
$error = "";
} else {
$error = $subreg->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else { $error = "Автопродление домена не возможно, т.к. $registrator->type - неизвестный тип регистратора"; }
if (!$error) {
$domain = GetDomainById($domain_id);
$tpl=GetTpl('email_touser_domain_renewok', $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);
WriteMailLog($subject,$template,$user->id);
sendmail($user->email,$company_name,$manager_email,$subject,$template,'','',$tpl[type]);
sendmail($user->email2,$company_name,$manager_email,$subject,$template,'','',$tpl[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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function getNS($domain_id) {
global $GLOBALerror, $_lang, $full_home_path, $onlinenicDomainTypes, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$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 = decodePwd($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 = decodePwd($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") {
$naunet_url = $registrator->url;
$naunet_user = $registrator->text1;
$naunet_password = decodePwd($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 if ($registrator->type == "nicru") {
$nicru_url = $registrator->url;
$nicru_user = $registrator->text1;
$nicru_password = decodePwd($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->domain);
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 = decodePwd($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 = decodePwd($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;
}
$hostmaster->disconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "hostmasterepp") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($registrator->text2);
$hostmaster_ssl = $registrator->text3;
$hostmaster_log = $registrator->check1;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTEREPP;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password,$hostmaster_ssl,$hostmaster_log);
$result=$hostmaster->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $hostmaster->error;
}
$hostmaster->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "nicdpua") {
$nicdpua_url = $registrator->url;
$nicdpua_port = $registrator->port;
$nicdpua_user = $registrator->text1;
$nicdpua_password = decodePwd($registrator->text2);
$nicdpua_ssl = $registrator->text3;
$nicdpua_log = $registrator->check1;
if ($nicdpua_url and $nicdpua_port and $nicdpua_user and $nicdpua_password) {
$nicdpua = new NICDPUA;
$nicdpua->init($nicdpua_url,$nicdpua_port,$nicdpua_user,$nicdpua_password,$nicdpua_ssl,$nicdpua_log);
$result=$nicdpua->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $nicdpua->error;
}
$nicdpua->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "hosterby") {
$hosterby_url = $registrator->url;
$hosterby_port = $registrator->port;
$hosterby_user = $registrator->text1;
$hosterby_password = decodePwd($registrator->text2);
$hosterby_log = $registrator->check1;
if ($hosterby_url and $hosterby_port and $hosterby_user and $hosterby_password) {
$hosterby = new HOSTERBY;
$hosterby->init($hosterby_url,$hosterby_port,$hosterby_user,$hosterby_password,$hosterby_log);
$result=$hosterby->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $hosterby->error;
}
$hosterby->logout();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "networking4all") {
$n4all_url = $registrator->url;
$n4all_user = $registrator->text1;
$n4all_password = decodePwd($registrator->text2);
$n4all_handle = $registrator->text3;
if ($n4all_url and $n4all_user and $n4all_password and $n4all_handle) {
$n4all = new NETWORKING4ALL;
$n4all->init($n4all_url,$n4all_user,$n4all_password,$n4all_handle);
$result = $n4all->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $n4all->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 = decodePwd($registrator->text2);
if ($onlinenic_url and $onlinenic_port and $onlinenic_user and $onlinenic_password) {
$zidx = mb_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") {
$directi_url = $registrator->url;
$directi_user = $registrator->text1;
$directi_password = decodePwd($registrator->text2);
$directi_parentid = $registrator->check1;
if ($directi_url and $directi_user and $directi_password) {
if ($domain->estOrderId) {
$directi = new DIRECTI;
$directi->init($directi_url,$directi_user,$directi_password,$directi_log);
$result = $directi->getNS($domain->estOrderId);
if (is_array($result)) {
$error = "";
} else {
$error = $directi->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." OrderId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "todaynic") {
$todaynic_url = $registrator->url;
$todaynic_user = $registrator->text1;
$todaynic_password = decodePwd($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 = decodePwd($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 = decodePwd($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 = decodePwd($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 = decodePwd($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 = decodePwd($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 if ($registrator->type == "rrpproxy") {
$rrpproxy_url = $registrator->url;
$rrpproxy_user = $registrator->text1;
$rrpproxy_password = decodePwd($registrator->text2);
if ($rrpproxy_url and $rrpproxy_user and $rrpproxy_password) {
$rrpproxy = new RRPPROXY;
$rrpproxy->init($rrpproxy_url,$rrpproxy_user,$rrpproxy_password);
$result=$rrpproxy->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $rrpproxy->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "ppua") {
$ppua_url = $registrator->url;
$ppua_port = $registrator->port;
$ppua_user = $registrator->text1;
$ppua_password = decodePwd($registrator->text2);
$ppua_log = $registrator->check1;
if ($ppua_url and $ppua_port and $ppua_user and $ppua_password) {
$ppua = new PPUA;
$ppua->init($ppua_url,$ppua_port,$ppua_user,$ppua_password,$ppua_log);
$result=$ppua->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $ppua->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "websitews") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
$rgstr = new WEBSITEWS;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_password);
$result = $rgstr->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $rgstr->error;
}
$rgstr->disconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "namecheap") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new NAMECHEAP;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log, $ip);
$result = $rgstr->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "pskz") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new PSKZ;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log);
$result = $rgstr->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "dotfm") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
$rgstr = new DOTFM;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_password);
$result = $rgstr->getNS($domain->domain);
if (is_array($result)) {
$rgstr->disconnect();
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "cnic") {
$cnic_url = $registrator->url;
$cnic_user = $registrator->text1;
$cnic_password = decodePwd($registrator->text2);
$cnic_registrar = $registrator->text3;
if ($cnic_url and $cnic_user and $cnic_password and $cnic_registrar) {
$cnic = new CNIC;
$cnic->init($cnic_url,$cnic_user,$cnic_password,$cnic_registrar);
$result=$cnic->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $cnic->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "gfx") {
$gfx_url = $registrator->url;
$gfx_user = $registrator->text1;
$gfx_password = decodePwd($registrator->text2);
$gfx_registrar = $registrator->text3;
if ($gfx_url and $gfx_user and $gfx_password) {
$gfx = new GFX;
$gfx->init($gfx_url,$gfx_user,$gfx_password,$gfx_registrar);
$result=$gfx->getNS($domain->gfxDomainId);
if (is_array($result)) {
$error = "";
} else {
$error = $gfx->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "internetbs") {
$internetbs_url = $registrator->url;
$internetbs_user = $registrator->text1;
$internetbs_password = decodePwd($registrator->text2);
if ($internetbs_url and $internetbs_user and $internetbs_password) {
$internetbs = new INTERNETBS;
$internetbs->init($internetbs_url,$internetbs_user,$internetbs_password);
$result=$internetbs->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $internetbs->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "rootpanel") {
$rp_url = $registrator->url;
$rp_user = $registrator->text1;
$rp_password = decodePwd($registrator->text2);
if ($rp_url and $rp_user and $rp_password) {
$rp = new ROOTPANELAPI;
$rp->init($rp_url,$rp_user,$rp_password);
$result=$rp->getDNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $rp->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "epag") {
$epag_url = $registrator->url;
$epag_port = $registrator->port;
$epag_user = $registrator->text1;
$epag_password = decodePwd($registrator->text2);
$epag_customerid = $registrator->text3;
if ($epag_url and $epag_port and $epag_user and $epag_password and $epag_customerid) {
$epag = new EPAG;
$epag->init($epag_url,$epag_port,$epag_user,$epag_password,$epag_customerid);
$result=$epag->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $epag->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "subreg") {
$subreg_url = $registrator->url;
$subreg_user = $registrator->text1;
$subreg_password = decodePwd($registrator->text2);
$subreg_log = $registrator->check1;
if ($subreg_url and $subreg_user and $subreg_password) {
$subreg = new SUBREG;
$subreg->init($subreg_url,$subreg_user,$subreg_password,$subreg_log);
$result = $subreg->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $subreg->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] = trim($result[0]);
$result[1] = trim($result[1]);
$result[2] = trim($result[2]);
$result[3] = trim($result[3]);
$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,$ns1ip='',$ns2ip='',$ns3ip='',$ns4ip='',$oldns1='',$oldns2='',$oldns3='',$oldns4='',$oldns1ip='',$oldns2ip='',$oldns3ip='',$oldns4ip='',$useDefaultNS=0) {
global $GLOBALerror, $_lang, $full_home_path, $onlinenicDomainTypes, $nicruService, $nicruTemplate, $authorization_key, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$ns1=trim($ns1);
$ns2=trim($ns2);
$ns3=trim($ns3);
$ns4=trim($ns4);
$oldns1=trim($oldns1);
$oldns2=trim($oldns2);
$oldns3=trim($oldns3);
$oldns4=trim($oldns4);
$ns1ip=trim($ns1ip);
$ns2ip=trim($ns2ip);
$ns3ip=trim($ns3ip);
$ns4ip=trim($ns4ip);
$oldns1ip=trim($oldns1ip);
$oldns2ip=trim($oldns2ip);
$oldns3ip=trim($oldns3ip);
$oldns4ip=trim($oldns4ip);
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($zone->autoreg) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->id) {
$user = GetUserById($domain->uid);
if ($user->id) {
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$profile = GetUserProfileByUserId($localContactUser->id, $zone->localContact);
} else {
$profile = GetUserProfileByUserId($user->id, $domain->profileId);
}
if ($useDefaultNS and !$domain->dnsServerId and !$domain->dnsServerIsShell and $zone->enableDefaultNS and $zone->enableCreateZone) {
if (createDomainZoneAtServer($domain->id, $ns1, $ns2, $ns3, $ns4, 1)) {
$error = "";
} else {
$error = $GLOBALerror;
}
}
$defaultDnsServer1 = trim(GetSetting("defaultDnsServer1"));
$defaultDnsServer2 = trim(GetSetting("defaultDnsServer2"));
if (!$error) {
if ($registrator->type == "regru") {
$regru_url = $registrator->url;
$regru_user = $registrator->text1;
$regru_password = decodePwd($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,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if ($result) {
$error = "";
} else {
$error = $regru->errors[0];
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "networking4all") {
$n4all_url = $registrator->url;
$n4all_user = $registrator->text1;
$n4all_password = decodePwd($registrator->text2);
$n4all_handle = $registrator->text3;
if ($n4all_url and $n4all_user and $n4all_password and $n4all_handle) {
$n4all = new NETWORKING4ALL;
$n4all->init($n4all_url,$n4all_user,$n4all_password,$n4all_handle);
$result = $n4all->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if ($result) {
$error = "";
} else {
$error = $n4all->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "webnames") {
$webnames_url = $registrator->url;
$webnames_user = $registrator->text1;
$webnames_password = decodePwd($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,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if ($result) {
$error = "";
} else {
$error = $webnames->errors[0];
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "naunet") {
$naunet_url = $registrator->url;
$naunet_user = $registrator->text1;
$naunet_password = decodePwd($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,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if ($result) {
$error = "";
} else {
$error = $naunet->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "nicru") {
$nicru_url = $registrator->url;
$nicru_user = $registrator->text1;
$nicru_password = decodePwd($registrator->text2);
if ($nicru_url and $nicru_user and $nicru_password) {
$zidx = mb_strtolower($zone->zone);
$service = $nicruService[$zidx];
$ntemplate = $nicruTemplate[$zidx];
if ($service and $ntemplate) {
$nicru = new NICRU;
$nicru->init($nicru_url,$nicru_user,$nicru_password);
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
if ($profile->nicruAnketaId) {
$private_person = "OFF";
$orderId=$nicru->updateRuNS($profile->nicruAnketaId,$service,$ntemplate,$domain->domain,"Private Domain",$private_person,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
}
else { $error = $_lang[DomainsErrorCantGetValue]." nicruAnketaId."; }
} else {
if ($profile->nicruAnketaId and $profile->nicruContactId) {
$orderId=$nicru->updateNS($profile->nicruAnketaId,$profile->nicruContactId,$service,$ntemplate,$domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
}
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 = decodePwd($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->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$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 = decodePwd($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);
if ($ns1 and !$ns1ip and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns1); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns1,"1.1.1.1"); } }
if ($ns2 and !$ns2ip and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns2); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns2,"1.1.1.1"); } }
if ($ns3 and !$ns3ip and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns3); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns3,"1.1.1.1"); } }
if ($ns4 and !$ns4ip and !$hostmaster->error) { $nsExistsIP = $hostmaster->getNSInfo($ns4); if (!$hostmaster->error and !$nsExistsIP) { $hostmaster->createNS($ns4,"1.1.1.1"); } }
if (!$hostmaster->error and $ns1ip) {
$nsExistsIP = $hostmaster->getNSInfo($ns1);
if (!$hostmaster->error and $nsExistsIP) {
if ($ns1ip != $nsExistsIP) {
$hostmaster->modifyNS($ns1, $ns1ip);
}
} else {
$hostmaster->createNS($ns1, $ns1ip);
}
}
if (!$hostmaster->error and $ns2ip) {
$nsExistsIP = $hostmaster->getNSInfo($ns2);
if (!$hostmaster->error and $nsExistsIP) {
if ($ns2ip != $nsExistsIP) {
$hostmaster->modifyNS($ns2, $ns2ip);
}
} else {
$hostmaster->createNS($ns2, $ns2ip);
}
}
if (!$hostmaster->error and $ns3ip) {
$nsExistsIP = $hostmaster->getNSInfo($ns3);
if (!$hostmaster->error and $nsExistsIP) {
if ($ns3ip != $nsExistsIP) {
$hostmaster->modifyNS($ns3, $ns3ip);
}
} else {
$hostmaster->createNS($ns3, $ns3ip);
}
}
if (!$hostmaster->error and $ns4ip) {
$nsExistsIP = $hostmaster->getNSInfo($ns4);
if (!$hostmaster->error and $nsExistsIP) {
if ($ns4ip != $nsExistsIP) {
$hostmaster->modifyNS($ns4, $ns4ip);
}
} else {
$hostmaster->createNS($ns4, $ns4ip);
}
}
if (!$hostmaster->error) {
$result=$hostmaster->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4);
if ($result) {
$error = "";
} else {
$error = $hostmaster->error;
}
} else {
$error = $hostmaster->error;
}
$hostmaster->disconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "hostmasterepp") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($registrator->text2);
$hostmaster_ssl = $registrator->text3;
$hostmaster_log = $registrator->check1;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTEREPP;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password,$hostmaster_ssl,$hostmaster_log);
$result=$hostmaster->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if ($result) {
$error = "";
} else {
$error = $hostmaster->error;
}
$hostmaster->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "nicdpua") {
$nicdpua_url = $registrator->url;
$nicdpua_port = $registrator->port;
$nicdpua_user = $registrator->text1;
$nicdpua_password = decodePwd($registrator->text2);
$nicdpua_ssl = $registrator->text3;
$nicdpua_log = $registrator->check1;
if ($nicdpua_url and $nicdpua_port and $nicdpua_user and $nicdpua_password) {
$nicdpua = new NICDPUA;
$nicdpua->init($nicdpua_url,$nicdpua_port,$nicdpua_user,$nicdpua_password,$nicdpua_ssl,$nicdpua_log);
$result=$nicdpua->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if ($result) {
$error = "";
} else {
$error = $nicdpua->error;
}
$nicdpua->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "hosterby") {
$hosterby_url = $registrator->url;
$hosterby_port = $registrator->port;
$hosterby_user = $registrator->text1;
$hosterby_password = decodePwd($registrator->text2);
$hosterby_log = $registrator->check1;
if ($hosterby_url and $hosterby_port and $hosterby_user and $hosterby_password) {
$hosterby = new HOSTERBY;
$hosterby->init($hosterby_url,$hosterby_port,$hosterby_user,$hosterby_password,$hosterby_log);
$result=$hosterby->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if ($result) {
$error = "";
} else {
$error = $hosterby->error;
}
$hosterby->logout();
}
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 = decodePwd($registrator->text2);
if ($onlinenic_url and $onlinenic_port and $onlinenic_user and $onlinenic_password) {
$zidx = mb_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 = decodePwd($domain->panel_pwd); } else { $pw = generatePassword(8,1); }
if ($oldns1ip or $oldns2ip or $oldns3ip or $oldns4ip) { $onlinenic->updateNS($domain->domain,$domaintype,$defaultDnsServer1,$defaultDnsServer2,'','',$pw); }
if (!$onlinenic->error and $oldns1ip) { $onlinenic->deleteNS($domaintype, $oldns1); }
if (!$onlinenic->error and $oldns2ip) { $onlinenic->deleteNS($domaintype, $oldns2); }
if (!$onlinenic->error and $oldns3ip) { $onlinenic->deleteNS($domaintype, $oldns3); }
if (!$onlinenic->error and $oldns4ip) { $onlinenic->deleteNS($domaintype, $oldns4); }
if (!$onlinenic->error and $ns1ip) { $onlinenic->createNS($domaintype, $ns1, $ns1ip); }
if (!$onlinenic->error and $ns2ip) { $onlinenic->createNS($domaintype, $ns2, $ns2ip); }
if (!$onlinenic->error and $ns3ip) { $onlinenic->createNS($domaintype, $ns3, $ns3ip); }
if (!$onlinenic->error and $ns4ip) { $onlinenic->createNS($domaintype, $ns4, $ns4ip); }
if (!$onlinenic->error) {
$result = $onlinenic->updateNS($domain->domain,$domaintype,$ns1,$ns2,$ns3,$ns4,$pw);
if ($result) {
$error = "";
} else {
$error = $onlinenic->error;
}
} else {
$error = $onlinenic->error;
}
}
else { $error = $_lang[DomainsErrorZoneNotSupported]; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "directi") {
$directi_url = $registrator->url;
$directi_user = $registrator->text1;
$directi_password = decodePwd($registrator->text2);
$directi_parentid = $registrator->check1;
if ($directi_url and $directi_user and $directi_password) {
if ($domain->estOrderId) {
$directi = new DIRECTI;
$directi->init($directi_url,$directi_user,$directi_password,$directi_log);
if ($oldns1ip or $oldns2ip or $oldns3ip or $oldns4ip) { $directi->updateNS($domain->estOrderId, $defaultDnsServer1, $defaultDnsServer2, '', ''); }
if (!$directi->error and $oldns1ip) { $directi->deleteChildNameServerIp($domain->estOrderId, $oldns1, $oldns1ip); }
if (!$directi->error and $oldns2ip) { $directi->deleteChildNameServerIp($domain->estOrderId, $oldns2, $oldns2ip); }
if (!$directi->error and $oldns3ip) { $directi->deleteChildNameServerIp($domain->estOrderId, $oldns3, $oldns3ip); }
if (!$directi->error and $oldns4ip) { $directi->deleteChildNameServerIp($domain->estOrderId, $oldns4, $oldns4ip); }
if (!$directi->error and $ns1ip) { $directi->addChildNameServer($domain->estOrderId, $ns1, $ns1ip); }
if (!$directi->error and $ns2ip) { $directi->addChildNameServer($domain->estOrderId, $ns2, $ns2ip); }
if (!$directi->error and $ns3ip) { $directi->addChildNameServer($domain->estOrderId, $ns3, $ns3ip); }
if (!$directi->error and $ns4ip) { $directi->addChildNameServer($domain->estOrderId, $ns4, $ns4ip); }
if (!$directi->error) {
$result = $directi->updateNS($domain->estOrderId, $ns1, $ns2, $ns3, $ns4);
if ($result) {
$error = "";
} else {
$error = $directi->error;
}
} else {
$error = $directi->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." OrderId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "todaynic") {
$todaynic_url = $registrator->url;
$todaynic_user = $registrator->text1;
$todaynic_password = decodePwd($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,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
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) {
$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;}
else if (preg_match("/{eunic}/ui",$mail_body)) { $nichandle = $profile->eunic; $needHandle = 1;}
else if (preg_match("/{dpnic}/ui",$mail_body)) { $nichandle = $profile->dpnic; $needHandle = 1;}
else if (preg_match("/{epnic}/ui",$mail_body)) { $nichandle = $profile->epnic; $needHandle = 1;}
if (!$nichandle) { $nichandle = $mail_nichandle; }
if ($nichandle or !$needHandle) {
$nslistcode = "nserver: $ns1"; if ($ns1ip) { $nslistcode .= " $ns1ip";}
$nslistcode .= "rnnserver: $ns2"; if ($ns2ip) { $nslistcode .= " $ns2ip";}
if ($ns3) { $nslistcode .= "rnnserver: $ns3"; if ($ns3ip) { $nslistcode .= " $ns3ip";} }
if ($ns4) { $nslistcode .= "rnnserver: $ns4"; if ($ns4ip) { $nslistcode .= " $ns4ip";} }
if (preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain->domain)) {
$idna = new idna_convert();
$domain->domain = $idna->encode($domain->domain);
}
$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('{ns1}',$ns1,$mail_body);
$mail_body = str_replace('{ns1ip}',$ns1ip,$mail_body);
$mail_body = str_replace('{ns2}',$ns2,$mail_body);
$mail_body = str_replace('{ns2ip}',$ns2ip,$mail_body);
$mail_body = str_replace('{ns3}',$ns3,$mail_body);
$mail_body = str_replace('{ns3ip}',$ns3ip,$mail_body);
$mail_body = str_replace('{ns4}',$ns4,$mail_body);
$mail_body = str_replace('{ns4ip}',$ns4ip,$mail_body);
$mail_body = str_replace('{uanic}',$nichandle,$mail_body);
$mail_body = str_replace('{eunic}',$nichandle,$mail_body);
$mail_body = str_replace('{dpnic}',$nichandle,$mail_body);
$mail_body = str_replace('{epnic}',$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//IGNORE", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-R//IGNORE", $mail_body);
} else if ($usekoi8u) {
$encoding = "KOI8-U";
$mail_subject = iconv("UTF-8", "KOI8-U//IGNORE", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-U//IGNORE", $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,'','','text',$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 = decodePwd($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,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
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 = decodePwd($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,$ns1ip,$ns2ip,$ns3ip,$ns4ip, $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 = decodePwd($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);
if ($oldns1ip or $oldns2ip or $oldns3ip or $oldns4ip) { $ukrnames->updateNS($domain->domain,$defaultDnsServer1,$defaultDnsServer2,'',''); }
# if (!$ukrnames->error and $oldns1ip) { $ukrnames->deleteNS($oldns1, $oldns1ip, $zone->zone); }
# if (!$ukrnames->error and $oldns2ip) { $ukrnames->deleteNS($oldns2, $oldns2ip, $zone->zone); }
# if (!$ukrnames->error and $oldns3ip) { $ukrnames->deleteNS($oldns3, $oldns3ip, $zone->zone); }
# if (!$ukrnames->error and $oldns4ip) { $ukrnames->deleteNS($oldns4, $oldns4ip, $zone->zone); }
if (!$ukrnames->error and $ns1ip) { $ukrnames->createNS($ns1, $ns1ip, $zone->zone); }
if (!$ukrnames->error and $ns2ip) { $ukrnames->createNS($ns2, $ns2ip, $zone->zone); }
if (!$ukrnames->error and $ns3ip) { $ukrnames->createNS($ns3, $ns3ip, $zone->zone); }
if (!$ukrnames->error and $ns4ip) { $ukrnames->createNS($ns4, $ns4ip, $zone->zone); }
if (!$ukrnames->error) {
$result=$ukrnames->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4);
if ($result) {
$error = "";
} else {
$error = $ukrnames->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 = decodePwd($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,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$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 = decodePwd($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,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if ($result) {
$error = "";
} else {
$error = $ficora->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." Authorization Key."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "rrpproxy") {
$rrpproxy_url = $registrator->url;
$rrpproxy_user = $registrator->text1;
$rrpproxy_password = decodePwd($registrator->text2);
if ($rrpproxy_url and $rrpproxy_user and $rrpproxy_password) {
$rrpproxy = new RRPPROXY;
$rrpproxy->init($rrpproxy_url,$rrpproxy_user,$rrpproxy_password);
if ($oldns1ip or $oldns2ip or $oldns3ip or $oldns4ip) { $rrpproxy->updateNS($domain->domain, $defaultDnsServer1, $defaultDnsServer1, '', ''); }
if (!$rrpproxy->error and $oldns1ip) { $rrpproxy->DeleteNameserver($oldns1); }
if (!$rrpproxy->error and $oldns2ip) { $rrpproxy->DeleteNameserver($oldns2); }
if (!$rrpproxy->error and $oldns3ip) { $rrpproxy->DeleteNameserver($oldns3); }
if (!$rrpproxy->error and $oldns4ip) { $rrpproxy->DeleteNameserver($oldns4); }
if (!$rrpproxy->error and $ns1ip) { $rrpproxy->AddNameserver($ns1, $ns1ip); }
if (!$rrpproxy->error and $ns2ip) { $rrpproxy->AddNameserver($ns2, $ns2ip); }
if (!$rrpproxy->error and $ns3ip) { $rrpproxy->AddNameserver($ns3, $ns3ip); }
if (!$rrpproxy->error and $ns4ip) { $rrpproxy->AddNameserver($ns4, $ns4ip); }
if (!$rrpproxy->error) {
$result=$rrpproxy->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4);
if ($result) {
$error = "";
} else {
$error = $rrpproxy->error;
}
} else {
$error = $rrpproxy->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "ppua") {
$ppua_url = $registrator->url;
$ppua_port = $registrator->port;
$ppua_user = $registrator->text1;
$ppua_password = decodePwd($registrator->text2);
$ppua_log = $registrator->check1;
if ($ppua_url and $ppua_port and $ppua_user and $ppua_password) {
$ppua = new PPUA;
$ppua->init($ppua_url,$ppua_port,$ppua_user,$ppua_password,$ppua_log);
$result=$ppua->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if ($result) {
$error = "";
} else {
$error = $ppua->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "websitews") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
$rgstr = new WEBSITEWS;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_password);
$result = $rgstr->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip);
if ($result) {
$error = "";
} else {
$error = $rgstr->error;
}
$rgstr->disconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "namecheap") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new NAMECHEAP;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log, $ip);
$result = $rgstr->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip);
if ($result) {
$error = "";
} else {
$error = $rgstr->error;
}
$rgstr->disconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "pskz") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new PSKZ;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log);
$result = $rgstr->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip);
if ($result) {
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "dotfm") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
$rgstr = new DOTFM;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_password);
$result = $rgstr->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip);
if ($result) {
$rgstr->disconnect();
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "cnic") {
$cnic_url = $registrator->url;
$cnic_user = $registrator->text1;
$cnic_password = decodePwd($registrator->text2);
$cnic_registrar = $registrator->text3;
if ($cnic_url and $cnic_user and $cnic_password and $cnic_registrar) {
$cnic = new CNIC;
$cnic->init($cnic_url,$cnic_user,$cnic_password,$cnic_registrar);
$result=$cnic->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if (is_array($result)) {
$error = "";
} else {
$error = $cnic->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "gfx") {
$gfx_url = $registrator->url;
$gfx_user = $registrator->text1;
$gfx_password = decodePwd($registrator->text2);
$gfx_registrar = $registrator->text3;
if ($gfx_url and $gfx_user and $gfx_password) {
if ($domain->gfxDomainId) {
$gfx = new GFX;
$gfx->init($gfx_url,$gfx_user,$gfx_password,$gfx_registrar);
$result = $gfx->updateNS($domain->gfxDomainId, $ns1, $ns2, $ns3, $ns4);
if ($result) {
$error = "";
} else {
$error = $gfx->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." gfxDomainId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "internetbs") {
$internetbs_url = $registrator->url;
$internetbs_user = $registrator->text1;
$internetbs_password = decodePwd($registrator->text2);
if ($internetbs_url and $internetbs_user and $internetbs_password) {
$internetbs = new INTERNETBS;
$internetbs->init($internetbs_url,$internetbs_user,$internetbs_password);
$result = $internetbs->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if ($result) {
$error = "";
} else {
$error = $internetbs->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "rootpanel") {
$rp_url = $registrator->url;
$rp_user = $registrator->text1;
$rp_password = decodePwd($registrator->text2);
if ($rp_url and $rp_user and $rp_password) {
$rp = new ROOTPANELAPI;
$rp->init($rp_url,$rp_user,$rp_password);
$result = $rp->updateDNS($domain->domain, 0, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip);
if ($result) {
$error = "";
} else {
$error = $rp->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "epag") {
$epag_url = $registrator->url;
$epag_port = $registrator->port;
$epag_user = $registrator->text1;
$epag_password = decodePwd($registrator->text2);
$epag_customerid = $registrator->text3;
if ($epag_url and $epag_port and $epag_user and $epag_password and $epag_customerid) {
$nichandle = $profile->epnic;
$epag = new EPAG;
$epag->init($epag_url,$epag_port,$epag_user,$epag_password,$epag_customerid);
$result=$epag->updateNS($domain->domain,$nichandle,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip);
if ($result) {
$error = "";
} else {
$error = $epag->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "subreg") {
$subreg_url = $registrator->url;
$subreg_user = $registrator->text1;
$subreg_password = decodePwd($registrator->text2);
$subreg_log = $registrator->check1;
if ($subreg_url and $subreg_user and $subreg_password) {
$subreg = new SUBREG;
$subreg->init($subreg_url,$subreg_user,$subreg_password,$subreg_log);
$result = $subreg->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip);
if ($result) {
$error = "";
} else {
$error = $subreg->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 #$orderid."; }
if ($error) {
$GLOBALerror = $error;
return false;
} else {
return true;
}
}
function updateDomainContact($domain_id, $profileId, $sendErrorEmail = 1) {
global $GLOBALerror, $_lang, $full_home_path, $onlinenicDomainTypes, $nicruService, $nicruTemplate, $startedRegion, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($domain->autoregby) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->active) {
$registratorId = $registrator->id;
$user = GetUserById($domain->uid);
if ($user->id) {
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$isR = 1; $chkProfile = "max";
} else {
$isD = 1;
$chkProfile = GetSetting("checkprofiletype");
if (mb_strtolower($zone->zone) == "pp.ua") { $rF[] = "mobile"; }
}
if (checkProfile($chkProfile, $user->id, $profileId, $rF)) {
if (mb_strtolower($zone->zone) == "ru") { $isR = 1; $isD=""; } else { $isD = 1; $isR="";}
if (checkProfileByAdmin($user->id, $profileId)) {
$profile = GetUserProfileByUserId($user->id, $profileId);
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$currentProfile = GetUserProfileByUserId($localContactUser->id, $zone->localContact);
} else {
$currentProfile = GetUserProfileByUserId($user->id, $domain->profileId);
}
if ($registrator->type != "started" and $registrator->type != "r01" and $registrator->type != "rootpanel") {
$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 ($registrator->type == "ukrnames") {
$ukrnames_url = $registrator->url;
$ukrnames_port = $registrator->port;
$ukrnames_user = $registrator->text1;
$ukrnames_password = decodePwd($registrator->text2);
if ($ukrnames_url and $ukrnames_port and $ukrnames_user and $ukrnames_password) {
if ($domain->panel_pwd) { $pw = decodePwd($domain->panel_pwd); } else { $pw = generatePassword(8,1); }
$ukrnames = new UKRNAMES;
$ukrnames->init($ukrnames_url,$ukrnames_port,$ukrnames_user,$ukrnames_password);
if ($domain->ukrnamesContactId) {
$contactId = $domain->ukrnamesContactId; $contactId = @mb_split(",",$contactId);
$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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
$ukrnames->updateContact($contactId[0],$name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$profile->email,$pw);
if (!$ukrnames->error) { $ukrnames->updateContact($contactId[1],$name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$profile->email,$pw); }
if (!$ukrnames->error) { $ukrnames->updateContact($contactId[2],$name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$profile->email,$pw); }
if (!$ukrnames->error) { $ukrnames->updateContact($contactId[3],$name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$profile->email,$pw); }
mconnect();
if (!$ukrnames->error) {
$error = "";
} else {
$error = $ukrnames->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." ukrnamesContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "ppua") {
$ppua_url = $registrator->url;
$ppua_port = $registrator->port;
$ppua_user = $registrator->text1;
$ppua_password = decodePwd($registrator->text2);
$ppua_log = $registrator->check1;
if ($ppua_url and $ppua_port and $ppua_user and $ppua_password) {
if ($domain->panel_pwd) { $pw = decodePwd($domain->panel_pwd); } else { $pw = generatePassword(8,0); }
$ppua = new PPUA;
$ppua->init($ppua_url,$ppua_port,$ppua_user,$ppua_password,$ppua_log);
if ($domain->ppuaContactId) {
$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);
if (mb_strtolower($zone->zone) == "pp.ua") {
$mobile = mb_split(" ",$profile->mobile); $mobile = $mobile[0].".".$mobile[1].$mobile[2];
} else {
$mobile = mb_split(" ",$profile->phone); $mobile = $mobile[0].".".$mobile[1].$mobile[2];
}
$result=$ppua->updateContact($domain->ppuaContactId,$name,$org,$street,$city,$oblast,$profile->post,$profile->country,$mobile,$profile->email,$pw);
mconnect();
if ($result) {
$error = "";
} else {
$error = $ppua->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." ppuaContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "websitews") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
if ($domain->panel_pwd) { $pw = decodePwd($domain->panel_pwd); } else { $pw = generatePassword(8,0); }
$rgstr = new WEBSITEWS;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_password);
if ($domain->websitewsContactId) {
$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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
$result = $rgstr->updateContact($domain->websitewsContactId, $name, $org, $street, $city, $oblast, $profile->post, $profile->country, $phone, $profile->email, $pw);
mconnect();
if ($result) {
$error = "";
} else {
$error = $rgstr->error;
}
$rgstr->disconnect();
}
else { $error = $_lang[DomainsErrorCantGetValue]." websitewsContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "namecheap") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new NAMECHEAP;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log, $ip);
if ($profile->org == "3") { $OrganizationName = $profile->firmaeng;}
$FirstName = GotoTranslit($profile->name);
$LastName = GotoTranslit($profile->surname);
$Address1 = GotoTranslit($profile->street);
$City = GotoTranslit($profile->city);
if ($profile->oblast) { $StateProvince = GotoTranslit($profile->oblast); } else { $StateProvince = "NA"; }
$PostalCode = $profile->post;
$Country = $profile->country;
$Phone = mb_split(" ",$profile->phone); $Phone = $Phone[0].".".$Phone[1].$Phone[2];
if ($profile->fax) { $Fax = mb_split(" ",$profile->fax); $Fax = $Fax[0].".".$Fax[1].$Fax[2]; }
$Email = $profile->email;
$result = $rgstr->updateContactsDomain($domain->domain, $OrganizationName, $FirstName, $LastName, $Address1, $City, $StateProvince, $PostalCode, $Country, $Phone, $Fax, $Email);
mconnect();
if ($result) {
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "pskz") {
$rgstr_url = $registrator->url;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
$rgstr_log = $registrator->check1;
if ($rgstr_url and $rgstr_user and $rgstr_password) {
$rgstr = new PSKZ;
$rgstr->init($rgstr_url, $rgstr_user, $rgstr_password, $rgstr_log);
if ($domain->pskzContactId) {
$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);
$result = $rgstr->updateContact($domain->pskzContactId, $name, $org, $profile->country, $oblast, $profile->post, $city, $street, $profile->email, $profile->phone, $profile->fax);
mconnect();
if ($result) {
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." pskzContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "dotfm") {
$rgstr_url = $registrator->url;
$rgstr_port = $registrator->port;
$rgstr_user = $registrator->text1;
$rgstr_password = decodePwd($registrator->text2);
if ($rgstr_url and $rgstr_port and $rgstr_user and $rgstr_password) {
if ($domain->panel_pwd) { $pw = decodePwd($domain->panel_pwd); } else { $pw = generatePassword(8,0); }
$rgstr = new DOTFM;
$rgstr->init($rgstr_url, $rgstr_port, $rgstr_user, $rgstr_password);
if ($domain->dotfmContactId) {
$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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
$result = $rgstr->updateContact($domain->dotfmContactId, $name, $org, $street, $city, $oblast, $profile->post, $profile->country, $phone, $profile->email, $pw);
mconnect();
if ($result) {
$rgstr->disconnect();
$error = "";
} else {
$error = $rgstr->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." dotfmContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "todaynic") {
$todaynic_url = $registrator->url;
$todaynic_user = $registrator->text1;
$todaynic_password = decodePwd($registrator->text2);
if ($todaynic_url and $todaynic_user and $todaynic_password) {
$todaynic = new TODAYNIC;
$todaynic->init($todaynic_url,$todaynic_user,$todaynic_password);
if ($domain->todaynicContactId) {
$contactId = $domain->todaynicContactId; $contactId = @mb_split(",",$contactId);
$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) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; }
$todaynic->updateContact($contactId[0], "registrant", $domain->domain, $name, $company, $profile->country, "", $profile->post, $city, $address1, $telNo, $faxNo, "", $profile->email);
if (!$todaynic->error) {$todaynic->updateContact($contactId[1], "admin", $domain->domain, $name, $company, $profile->country, "", $profile->post, $city, $address1, $telNo, $faxNo, "", $profile->email);}
if (!$todaynic->error) {$todaynic->updateContact($contactId[2], "tech", $domain->domain, $name, $company, $profile->country, "", $profile->post, $city, $address1, $telNo, $faxNo, "", $profile->email);}
if (!$todaynic->error) {$todaynic->updateContact($contactId[3], "billing", $domain->domain, $name, $company, $profile->country, "", $profile->post, $city, $address1, $telNo, $faxNo, "", $profile->email);}
mconnect();
if (!$todaynic->error) {
$error = "";
} else {
$error = $todaynic->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." todaynicContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "rrpproxy") {
$rrpproxy_url = $registrator->url;
$rrpproxy_user = $registrator->text1;
$rrpproxy_password = decodePwd($registrator->text2);
if ($rrpproxy_url and $rrpproxy_user and $rrpproxy_password) {
$rrpproxy = new RRPPROXY;
$rrpproxy->init($rrpproxy_url,$rrpproxy_user,$rrpproxy_password);
if ($currentProfile->rrpproxyContactId) {
$Firstname = GotoTranslit($profile->name);
$Lastname = GotoTranslit($profile->surname);
$Middlename = GotoTranslit($profile->otchestvo);
if ($profile->org == "3") { $Organization = $profile->firmaeng; }
$Street = GotoTranslit($profile->street);
$City = GotoTranslit($profile->city);
$State = GotoTranslit($profile->oblast);
$result=$rrpproxy->updateContact($currentProfile->rrpproxyContactId,$Firstname,$Middlename,$Lastname,$Organization,$Street,$City,$State,$profile->post,$profile->country,$profile->phone,$profile->fax,$profile->email);
mconnect();
if ($result) {
$error = "";
} else {
$error = $rrpproxy->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." rrpproxyContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "webnames") {
$webnames_url = $registrator->url;
$webnames_user = $registrator->text1;
$webnames_password = decodePwd($registrator->text2);
if ($webnames_url and $webnames_user and $webnames_password) {
$webnames = new WEBNAMES;
$webnames->init($webnames_url,$webnames_user,$webnames_password);
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$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);
if ($domain->privacy) {
$private_person = 1;
} else {
$private_person = 0;
}
$result=$webnames->updateRuDomainPerson($domain->domain,$person,$private_person,$person_r,$passport,$birth_date,$profile->country,$p_addr,$profile->phone,$profile->fax,$profile->email,$profile->inn);
} else if ($profile->org == "3") {
$result=$webnames->updateRuDomainOrg($domain->domain,$profile->firmaeng,$profile->firma,$profile->inn,$profile->kpp,$profile->country,$profile->address_org,$p_addr,$profile->phone,$profile->fax,$profile->email);
}
} else if (mb_strtolower($zone->zone) == "kz" or mb_strtolower($zone->zone) == "uz" or mb_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) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; }
$result=$webnames->updateKzUzTjDomain($domain->domain,$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) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; }
$o_addr = GotoTranslit($profile->street);
$o_city = GotoTranslit($profile->city);
$o_state = GotoTranslit($profile->oblast);
if (mb_strtolower($zone->zone) == "asia") { $default_ced = "1"; } else { $default_ced = ""; }
$result=$webnames->updateOtherDomain($domain->domain,$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) {
$error = "";
} else {
$error = $webnames->errors[0];
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "regru") {
$regru_url = $registrator->url;
$regru_user = $registrator->text1;
$regru_password = decodePwd($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 (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$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->updateRuDomainPerson($domain->domain,$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->updateRuDomainOrg($domain->domain,$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) = mb_split(" ", $profile->phone);
$o_phone = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) {
list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax);
$o_fax = $faxNoCc.".".$faxNo1."".$faxNo2;
}
$o_addr = GotoTranslit($profile->street);
$o_city = GotoTranslit($profile->city);
$o_state = "NA";
$result=$regru->updateEtcDomain($domain->domain,$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) {
$error = "";
} else {
$error = $regru->errors[0];
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "cnic") {
$cnic_url = $registrator->url;
$cnic_user = $registrator->text1;
$cnic_password = decodePwd($registrator->text2);
$cnic_registrar = $registrator->text3;
if ($cnic_url and $cnic_user and $cnic_password and $cnic_registrar) {
$cnic = new CNIC;
$cnic->init($cnic_url,$cnic_user,$cnic_password,$cnic_registrar);
if ($domain->cnicHandleId) {
$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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; }
if ($domain->privacy) {
$visible = 0;
} else {
$visible = 1;
}
$result = $cnic->updateHandle($domain->cnicHandleId,$name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$fax,$profile->email,$visible);
mconnect();
if ($result) {
$error = "";
} else {
$error = $cnic->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." cnicHandleId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "gfx") {
$gfx_url = $registrator->url;
$gfx_user = $registrator->text1;
$gfx_password = decodePwd($registrator->text2);
$gfx_registrar = $registrator->text3;
if ($gfx_url and $gfx_user and $gfx_password) {
$gfx = new GFX;
$gfx->init($gfx_url,$gfx_user,$gfx_password,$gfx_registrar);
if ($domain->gfxContactId) {
$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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; }
$result = $gfx->contact_save($domain->gfxContactId,$name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$fax,$profile->email);
mconnect();
if ($result) {
$error = "";
} else {
$error = $gfx->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." gfxContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "internetbs") {
$internetbs_url = $registrator->url;
$internetbs_user = $registrator->text1;
$internetbs_password = decodePwd($registrator->text2);
if ($internetbs_url and $internetbs_user and $internetbs_password) {
$internetbs = new INTERNETBS;
$internetbs->init($internetbs_url,$internetbs_user,$internetbs_password);
$name = GotoTranslit($profile->name);
$surname = GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng;}
$street = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
$phone = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; }
$result = $internetbs->contact_update($domain->domain,$zone->zone,$name,$surname,$org,$profile->country,$oblast,$city,$profile->email,$street,$profile->post,$phone,$fax,$profile->birthday,$ip);
mconnect();
if ($result) {
$error = "";
} else {
$error = $internetbs->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "rootpanel") {
$rp_url = $registrator->url;
$rp_user = $registrator->text1;
$rp_password = decodePwd($registrator->text2);
if ($rp_url and $rp_user and $rp_password) {
$rp = new ROOTPANELAPI;
$rp->init($rp_url,$rp_user,$rp_password);
$profileIdArray = parseRPStrArray($profile->rootpanelProfileId,":x:",":");
$profileId = $profileIdArray[$registratorId];
if ($currentProfile->id == $profile->id) {
# обновляем профайл через API
$result = $rp->updateProfile($profileId, $profile->surname, $profile->name, $profile->otchestvo, $profile->firma, $profile->firmaeng, $profile->country, $profile->oblast, $profile->post, $profile->city, $profile->street, $profile->komu, $profile->address_org, $profile->phone, $profile->mobile, $profile->fax, $profile->email, $profile->pasport_seriya, $profile->pasport_by, myDate($profile->pasport_date), myDate($profile->birthday), $profile->inn, $profile->kpp, $profile->okonh, $profile->okpo, $profile->bank, $profile->bank_schet, $profile->bank_bik, $profile->edrpou, $profile->socstrahnumber, $profile->ogrn, $profile->ogrn_by, myDate($profile->ogrn_date), $profile->icq, $profile->skype, $profile->ripe, $profile->ripn, $profile->uanic, $profile->dpnic, $profile->epnic, $profile->eunic);
if ($result) {
$error = "";
} else {
$error = $rp->error;
}
}
else if (!$profileId) {
$profileId = $rp->createProfile($profile->org, $profile->surname, $profile->name, $profile->otchestvo, $profile->firma, $profile->firmaeng, $profile->country, $profile->oblast, $profile->post, $profile->city, $profile->street, $profile->komu, $profile->address_org, $profile->phone, $profile->mobile, $profile->fax, $profile->email, $profile->pasport_seriya, $profile->pasport_by, myDate($profile->pasport_date), myDate($profile->birthday), $profile->inn, $profile->kpp, $profile->okonh, $profile->okpo, $profile->bank, $profile->bank_schet, $profile->bank_bik, $profile->edrpou, $profile->socstrahnumber, $profile->ogrn, $profile->ogrn_by, myDate($profile->ogrn_date), $profile->icq, $profile->skype, $profile->ripe, $profile->ripn, $profile->uanic, $profile->dpnic, $profile->epnic, $profile->eunic);
mconnect();
if ($profileId) {
$profileIdArray[$registratorId] = $profileId;
$profileIdString = parseRPArrayStr($profileIdArray,":x:",":");
@mysql_query("update users_profile set rootpanelProfileId='$profileIdString' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $rp->error;
}
}
if ($profileId and !$error) {
$result = $rp->updateDomainContacts($domain->domain,$profileId);
mconnect();
if ($result) {
@mysql_query("update orders_domains set profileId='$profile->id' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $rp->error;
}
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "internetx") {
$internetx_url = $registrator->url;
$internetx_user = $registrator->text1;
$internetx_password = decodePwd($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");
if ($currentProfile->internetxContactId) {
$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 = mb_split(" ",$profile->phone); $phone = $phone[0]."-".$phone[1]."-".$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0]."-".$fax[1]."-".$fax[2]; } else { $fax = $phone; }
if ($domain->privacy) {
$protection = "A";
} else {
$protection = "B";
}
$result=$internetx->updateContact($currentProfile->internetxContactId,$fname,$lname,$organization,$address,$profile->post,$city,$state,$profile->country,$phone,$fax,$profile->email,$protection,$manager_email);
mconnect();
if ($result) {
$error = "";
} else {
$error = $internetx->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." internetxContactId."; }
}
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 = decodePwd($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 ($profile->r01NicHandle) {
$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;
if ($domain->privacy) {
$isprotected = 1;
} else {
$isprotected = 0;
}
if ($profile->country == "RU") { $isresident = 1; } else { $isresident = 0; }
if ($profile->org == "1" or $profile->org == "2") {
$passport_date = mb_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 = mb_split("-", $profile->birthday); $birth_date = $birth_date[2]."-".$birth_date[1]."-".$birth_date[0];
$result=$r01->updateContactPerson($profile->r01NicHandle, $fiorus, GotoTranslit($fiorus), $passport, $birth_date, $postal_addr, $profile->phone, $profile->fax, $profile->email, $isprotected, $isresident);
} else if ($profile->org == "3") {
$nicHandle=$r01->updateContactOrg($profile->r01NicHandle, $profile->firma, $profile->firmaeng, $profile->inn, $profile->kpp, $profile->ogrn, $profile->address_org, $postal_addr, $profile->phone, $profile->fax, $profile->email, $fiorus, $profile->bank, $profile->bank_schet, $kor_schet, $profile->bank_bik, $isresident);
}
mconnect();
if ($result) {
$error = "";
} else {
$error = $r01->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." r01NicHandle."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "epag") {
$epag_url = $registrator->url;
$epag_port = $registrator->port;
$epag_user = $registrator->text1;
$epag_password = decodePwd($registrator->text2);
$epag_customerid = $registrator->text3;
if ($epag_url and $epag_port and $epag_user and $epag_password and $epag_customerid) {
$epag = new EPAG;
$epag->init($epag_url,$epag_port,$epag_user,$epag_password,$epag_customerid);
if ($currentProfile->epnic) {
$name = GotoTranslit($profile->name)." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng; $type = "Org";} else if ($profile->firma) { $company = GotoTranslit($profile->firma); $type = "Org"; } else { $type = "Person"; }
$street = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
$phone = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; } else { $fax = $phone; }
$result = $epag->updateContact($currentProfile->epnic,$type,$name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$fax,$profile->email);
mconnect();
if ($result) {
$error = "";
} else {
$error = $epag->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." EPNIC."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "hostmasterepp") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($registrator->text2);
$hostmaster_ssl = $registrator->text3;
$hostmaster_log = $registrator->check1;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTEREPP;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password,$hostmaster_ssl,$hostmaster_log);
if ($domain->hostmasterEppContactId) {
$name = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($profile->otchestvo,0,1))." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng; } else if ($profile->firma) { $org = GotoTranslit($profile->firma); } else { $org = ""; }
$address = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; } else { $faxNo = ""; }
# if ($domain->privacy) { $disclose = 0; } else { $disclose = 1; }
$disclose = 0;
$result = $hostmaster->updateContact($domain->hostmasterEppContactId, $name, $org, $address, $city, $oblast, $profile->post, $profile->country, $telNo, $faxNo, $profile->email, $disclose);
if ($result) {
$error = "";
} else {
$error = $hostmaster->error;
}
$hostmaster->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorCantGetValue]." hostmasterEppContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "nicdpua") {
$nicdpua_url = $registrator->url;
$nicdpua_port = $registrator->port;
$nicdpua_user = $registrator->text1;
$nicdpua_password = decodePwd($registrator->text2);
$nicdpua_ssl = $registrator->text3;
$nicdpua_log = $registrator->check1;
if ($nicdpua_url and $nicdpua_port and $nicdpua_user and $nicdpua_password) {
$nicdpua = new NICDPUA;
$nicdpua->init($nicdpua_url,$nicdpua_port,$nicdpua_user,$nicdpua_password,$nicdpua_ssl,$nicdpua_log);
if ($domain->nicdpuaContactId) {
$name = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($profile->otchestvo,0,1))." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng; } else if ($profile->firma) { $org = GotoTranslit($profile->firma); } else { $org = ""; }
$address = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; } else { $faxNo = ""; }
# if ($domain->privacy) { $disclose = 0; } else { $disclose = 1; }
$disclose = 0;
$result = $nicdpua->updateContact($domain->nicdpuaContactId, $name, $org, $address, $city, $oblast, $profile->post, $profile->country, $telNo, $faxNo, $profile->email, $disclose);
if ($result) {
$error = "";
} else {
$error = $nicdpua->error;
}
$nicdpua->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorCantGetValue]." nicdpuaContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "networking4all") {
$n4all_url = $registrator->url;
$n4all_user = $registrator->text1;
$n4all_password = decodePwd($registrator->text2);
$n4all_handle = $registrator->text3;
if ($n4all_url and $n4all_user and $n4all_password and $n4all_handle) {
$n4all = new NETWORKING4ALL;
$n4all->init($n4all_url,$n4all_user,$n4all_password,$n4all_handle);
if ($domain->networking4allContactId) {
$initials = GotoTranslit(mb_substr($profile->name,0,1)).".";
$firstName = GotoTranslit($profile->name);
$middleName = GotoTranslit($profile->otchestvo);
$lastName = GotoTranslit($profile->surname);
$street = GotoTranslit($profile->street);
$postalCode = $profile->post;
$city = GotoTranslit($profile->city);
if ($profile->oblast) { $province = GotoTranslit($profile->oblast); } else { $province = $city; }
$countryCode = $profile->country;
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $phoneNumber = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNumber = $faxNoCc.".".$faxNo1."".$faxNo2; } else { $faxNumber = ""; }
if ($profile->mobile) { list($mobNoCc,$mobNo1,$mobNo2) = mb_split(" ", $profile->mobile); $mobileNumber = $mobNoCc.".".$mobNo1."".$mobNo2; } else { $mobileNumber = ""; }
$email = $profile->email;
$result = $n4all->updateContact($domain->networking4allContactId, $initials, $firstName, $middleName, $lastName, $street, $postalCode, $city, $province, $countryCode, $phoneNumber, $faxNumber, $mobileNumber, $email);
mconnect();
if ($result) {
$error = "";
} else {
$error = $n4all->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." networking4allContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "subreg") {
$subreg_url = $registrator->url;
$subreg_user = $registrator->text1;
$subreg_password = decodePwd($registrator->text2);
$subreg_log = $registrator->check1;
if ($subreg_url and $subreg_user and $subreg_password) {
$subreg = new SUBREG;
$subreg->init($subreg_url,$subreg_user,$subreg_password,$subreg_log);
if ($domain->subregContactId) {
$name = GotoTranslit($profile->name);
$surname = GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng;}
$street = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$pc = $profile->post;
$sp = GotoTranslit($profile->oblast);
$cc = $profile->country;
$phone = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; }
$email = $profile->email;
$result = $subreg->updateContact($domain->subregContactId, $name, $surname, $org, $street, $city, $pc, $sp, $cc, $phone, $fax, $email);
mconnect();
if ($result) {
$error = "";
} else {
$error = $subreg->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." subregContactId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else { $error = $_lang[DomainsErrorRegistratorUnknown]." ($registrator->type)"; }
} else { $error = $_lang[DomainsErrorProfileNotCheckedByAdmin]; }
} else { $error = $_lang[DomainsErrorProfileNotFilled]." (".$GLOBALerror.")"; }
} else { $error = $_lang[DomainsErrorUserNotFound]; }
} else { $error = $_lang[DomainsErrorRegistratorInactive]; }
} else { $error = $_lang[DomainsErrorNoRegistrator]; }
} else { $error = $_lang[DomainsErrorZoneNotFound]; }
} else { $error = $_lang[DomainsErrorDomainOrdersNotFound]." ID #$domain_id."; }
$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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function createContactForExistsDomain($domain_id, $profileId, $sendErrorEmail = 1) {
global $GLOBALerror, $_lang, $full_home_path, $onlinenicDomainTypes, $nicruService, $nicruTemplate, $startedRegion, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($domain->autoregby) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->active) {
$registratorId = $registrator->id;
$user = GetUserById($domain->uid);
if ($user->id) {
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$isR = 1; $chkProfile = "max";
} else {
$isD = 1;
$chkProfile = GetSetting("checkprofiletype");
if (mb_strtolower($zone->zone) == "pp.ua") { $rF[] = "mobile"; }
}
if (checkProfile($chkProfile, $user->id, $profileId, $rF)) {
if (mb_strtolower($zone->zone) == "ru") { $isR = 1; $isD=""; } else { $isD = 1; $isR="";}
if (checkProfileByAdmin($user->id, $profileId)) {
$profile = GetUserProfileByUserId($user->id, $profileId);
# $localContactUser = GetUserByLogin(GetSetting("localContactUser"));
# if ($localContactUser->id and $zone->localContact and $domain->localContact) {
# $currentProfile = GetUserProfileByUserId($localContactUser->id, $zone->localContact);
# } else {
# $currentProfile = GetUserProfileByUserId($user->id, $domain->profileId);
# }
if ($registrator->type != "started" and $registrator->type != "r01" and $registrator->type != "rootpanel") {
$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 ($registrator->type == "ppua") {
$ppua_url = $registrator->url;
$ppua_port = $registrator->port;
$ppua_user = $registrator->text1;
$ppua_password = decodePwd($registrator->text2);
$ppua_log = $registrator->check1;
if ($ppua_url and $ppua_port and $ppua_user and $ppua_password) {
if ($domain->panel_pwd) { $pw = decodePwd($domain->panel_pwd); } else { $pw = generatePassword(8,0); }
$ppua = new PPUA;
$ppua->init($ppua_url,$ppua_port,$ppua_user,$ppua_password,$ppua_log);
if (!$domain->ppuaContactId) {
$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);
if (mb_strtolower($zone->zone) == "pp.ua") {
$mobile = mb_split(" ",$profile->mobile); $mobile = $mobile[0].".".$mobile[1].$mobile[2];
} else {
$mobile = mb_split(" ",$profile->phone); $mobile = $mobile[0].".".$mobile[1].$mobile[2];
}
$newContactId = $ppua->createContact($name,$org,$street,$city,$oblast,$profile->post,$profile->country,$mobile,$profile->email,$pw);
if ($newContactId) {
$result2 = $ppua->updateContactDomain($domain->domain, "", $newContactId, "");
mconnect();
if ($result2) {
@mysql_query("update orders_domains set ppuaContactId='$newContactId' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $ppua->error;
}
} else {
mconnect();
$error = $ppua->error;
}
}
else { $error = "ppuaContactId for domain already exists."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "hostmasterepp") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($registrator->text2);
$hostmaster_ssl = $registrator->text3;
$hostmaster_log = $registrator->check1;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTEREPP;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password,$hostmaster_ssl,$hostmaster_log);
if (!$domain->hostmasterEppContactId) {
$name = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($profile->otchestvo,0,1))." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng; } else if ($profile->firma) { $org = GotoTranslit($profile->firma); } else { $org = ""; }
$address = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; } else { $faxNo = ""; }
# if ($domain->privacy) { $disclose = 0; } else { $disclose = 1; }
$disclose = 0;
$newContactId = $hostmaster->createContact($name, $org, $address, $city, $oblast, $profile->post, $profile->country, $telNo, $faxNo, $profile->email, $disclose);
if ($newContactId) {
$result2 = $hostmaster->updateContactDomain($domain->domain, "", $newContactId, "");
mconnect();
if ($result2) {
@mysql_query("update orders_domains set hostmasterEppContactId='$newContactId' 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 = $hostmaster->error;
}
$hostmaster->logout();
mconnect();
}
else { $error = "hostmasterEppContactId for domain already exists."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "nicdpua") {
$nicdpua_url = $registrator->url;
$nicdpua_port = $registrator->port;
$nicdpua_user = $registrator->text1;
$nicdpua_password = decodePwd($registrator->text2);
$nicdpua_ssl = $registrator->text3;
$nicdpua_log = $registrator->check1;
if ($nicdpua_url and $nicdpua_port and $nicdpua_user and $nicdpua_password) {
$nicdpua = new NICDPUA;
$nicdpua->init($nicdpua_url,$nicdpua_port,$nicdpua_user,$nicdpua_password,$nicdpua_ssl,$nicdpua_log);
if (!$domain->nicdpuaContactId) {
$name = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($profile->otchestvo,0,1))." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng; } else if ($profile->firma) { $org = GotoTranslit($profile->firma); } else { $org = ""; }
$address = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
list($telNoCc,$telNo1,$telNo2) = mb_split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = mb_split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; } else { $faxNo = ""; }
# if ($domain->privacy) { $disclose = 0; } else { $disclose = 1; }
$disclose = 0;
$newContactId = $nicdpua->createContact($name, $org, $address, $city, $oblast, $profile->post, $profile->country, $telNo, $faxNo, $profile->email, $disclose);
if ($newContactId) {
$result2 = $nicdpua->updateContactDomain($domain->domain, "", $newContactId, "");
mconnect();
if ($result2) {
@mysql_query("update orders_domains set nicdpuaContactId='$newContactId' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $nicdpua->error;
}
} else {
$error = $nicdpua->error;
}
$hostmaster->logout();
mconnect();
}
else { $error = "nicdpuaContactId already exists for domain."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else { $error = $_lang[DomainsErrorRegistratorUnknown]." ($registrator->type)"; }
} else { $error = $_lang[DomainsErrorProfileNotCheckedByAdmin]; }
} else { $error = $_lang[DomainsErrorProfileNotFilled]." (".$GLOBALerror.")"; }
} else { $error = $_lang[DomainsErrorUserNotFound]; }
} else { $error = $_lang[DomainsErrorRegistratorInactive]; }
} else { $error = $_lang[DomainsErrorNoRegistrator]; }
} else { $error = $_lang[DomainsErrorZoneNotFound]; }
} else { $error = $_lang[DomainsErrorDomainOrdersNotFound]." ID #$domain_id."; }
$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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function updateDomainPrivacy($domain_id, $privacy, $sendErrorEmail = 1) {
global $GLOBALerror, $_lang, $full_home_path, $onlinenicDomainTypes, $nicruService, $nicruTemplate, $startedRegion, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$profileId = $domain->profileId;
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($domain->autoregby) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->active) {
$registratorId = $registrator->id;
$user = GetUserById($domain->uid);
if ($user->id) {
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$isR = 1; $chkProfile = "max";
} else {
$isD = 1;
$chkProfile = GetSetting("checkprofiletype");
if (mb_strtolower($zone->zone) == "pp.ua") { $rF[] = "mobile"; }
}
if (checkProfile($chkProfile, $user->id, $profileId, $rF)) {
if (mb_strtolower($zone->zone) == "ru") { $isR = 1; $isD=""; } else { $isD = 1; $isR="";}
if (checkProfileByAdmin($user->id, $profileId)) {
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$profile = GetUserProfileByUserId($localContactUser->id, $zone->localContact);
} else {
$profile = GetUserProfileByUserId($user->id, $profileId);
}
if ($registrator->type != "started" and $registrator->type != "r01" and $registrator->type != "rootpanel") {
$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 ($registrator->type == "cnic") {
$cnic_url = $registrator->url;
$cnic_user = $registrator->text1;
$cnic_password = decodePwd($registrator->text2);
$cnic_registrar = $registrator->text3;
if ($cnic_url and $cnic_user and $cnic_password and $cnic_registrar) {
$cnic = new CNIC;
$cnic->init($cnic_url,$cnic_user,$cnic_password,$cnic_registrar);
if ($domain->cnicHandleId) {
$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 = mb_split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0].".".$fax[1].$fax[2]; }
if ($privacy) {
$visible = 0;
} else {
$visible = 1;
}
$result = $cnic->updateHandle($domain->cnicHandleId,$name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$fax,$profile->email,$visible);
mconnect();
if ($result) {
$error = "";
} else {
$error = $cnic->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." cnicHandleId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "directi") {
$directi_url = $registrator->url;
$directi_user = $registrator->text1;
$directi_password = decodePwd($registrator->text2);
$directi_log = $registrator->check1;
if ($directi_url and $directi_user and $directi_password) {
if ($domain->estOrderId) {
$directi = new DIRECTI;
$directi->init($directi_url,$directi_user,$directi_password,$directi_log);
if ($privacy) {
$newIsPrivacyProtected = "true";
} else {
$newIsPrivacyProtected = "false";
}
$result = $directi->changePrivacyProtectionStatus($domain->estOrderId, $newIsPrivacyProtected, "Request by domain owner");
if ($result) {
$error = "";
} else {
$error = $directi->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." OrderId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "internetbs") {
$internetbs_url = $registrator->url;
$internetbs_user = $registrator->text1;
$internetbs_password = decodePwd($registrator->text2);
if ($internetbs_url and $internetbs_user and $internetbs_password) {
$internetbs = new INTERNETBS;
$internetbs->init($internetbs_url,$internetbs_user,$internetbs_password);
if ($privacy) {
$result = $internetbs->privateWhoisEnable($domain->domain);
} else {
$result = $internetbs->privateWhoisDisable($domain->domain);
}
mconnect();
if ($result) {
$error = "";
} else {
$error = $internetbs->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "internetx") {
$internetx_url = $registrator->url;
$internetx_user = $registrator->text1;
$internetx_password = decodePwd($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");
if ($profile->internetxContactId) {
$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 = mb_split(" ",$profile->phone); $phone = $phone[0]."-".$phone[1]."-".$phone[2];
if ($profile->fax) { $fax = mb_split(" ",$profile->fax); $fax = $fax[0]."-".$fax[1]."-".$fax[2]; } else { $fax = $phone; }
if ($privacy) {
$protection = "A";
} else {
$protection = "B";
}
$result=$internetx->updateContact($profile->internetxContactId,$fname,$lname,$organization,$address,$profile->post,$city,$state,$profile->country,$phone,$fax,$profile->email,$protection,$manager_email);
mconnect();
if ($result) {
$error = "";
} else {
$error = $internetx->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." internetxContactId."; }
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин, пароль или contextid для $registrator->name"; }
}
else if ($registrator->type == "naunet") {
$naunet_url = $registrator->url;
$naunet_user = $registrator->text1;
$naunet_password = decodePwd($registrator->text2);
if ($naunet_url and $naunet_user and $naunet_password) {
$naunet = new NAUNET;
$naunet->init($naunet_url,$naunet_user,$naunet_password);
if ($privacy) {
$privateWhois = "yes";
} else {
$privateWhois = "no";
}
$result=$naunet->updatePrivateWhois($domain->domain,$privateWhois);
if ($result) {
$error = "";
} else {
$error = $naunet->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "nicru") {
$nicru_url = $registrator->url;
$nicru_user = $registrator->text1;
$nicru_password = decodePwd($registrator->text2);
if ($nicru_url and $nicru_user and $nicru_password) {
$zidx = mb_strtolower($zone->zone);
$service = $nicruService[$zidx];
$ntemplate = $nicruTemplate[$zidx];
if ($service and $ntemplate) {
$nicru = new NICRU;
$nicru->init($nicru_url,$nicru_user,$nicru_password);
if ($profile->nicruAnketaId) {
if ($privacy) {
$private_person = "OFF";
} else {
$private_person = "ON";
}
$result=$nicru->updateRuPrivateWhois($profile->nicruAnketaId,$service,$ntemplate,$domain->domain,"Private Domain",$private_person);
}
else { $error = $_lang[DomainsErrorCantGetValue]." nicruAnketaId."; }
mconnect();
if ($result) {
$error = "";
} else {
$error = $nicru->error;
}
}
else { $error = $_lang[DomainsErrorZoneNotSupported]; }
}
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 = decodePwd($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 ($profile->r01NicHandle) {
$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;
if ($privacy) {
$isprotected = 1;
} else {
$isprotected = 0;
}
if ($profile->country == "RU") { $isresident = 1; } else { $isresident = 0; }
if ($profile->org == "1" or $profile->org == "2") {
$passport_date = mb_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 = mb_split("-", $profile->birthday); $birth_date = $birth_date[2]."-".$birth_date[1]."-".$birth_date[0];
$result=$r01->updateContactPerson($profile->r01NicHandle, $fiorus, GotoTranslit($fiorus), $passport, $birth_date, $postal_addr, $profile->phone, $profile->fax, $profile->email, $isprotected, $isresident);
} else if ($profile->org == "3") {
#
}
mconnect();
if ($result) {
$error = "";
} else {
$error = $r01->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." r01NicHandle."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "regru") {
$regru_url = $registrator->url;
$regru_user = $registrator->text1;
$regru_password = decodePwd($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 (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
if ($privacy) {
$private_person_flag = 1;
} else {
$private_person_flag = 0;
}
$result=$regru->updateRuDomainPrivatePerson($domain->domain,$private_person_flag);
}
mconnect();
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 = decodePwd($registrator->text2);
if ($webnames_url and $webnames_user and $webnames_password) {
$webnames = new WEBNAMES;
$webnames->init($webnames_url,$webnames_user,$webnames_password);
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$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);
if ($privacy) {
$private_person = 1;
} else {
$private_person = 0;
}
$result=$webnames->updateRuDomainPerson($domain->domain,$person,$private_person,$person_r,$passport,$birth_date,$profile->country,$p_addr,$profile->phone,$profile->fax,$profile->email,$profile->inn);
}
}
mconnect();
if ($result) {
$error = "";
} else {
$error = $webnames->errors[0];
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "subreg") {
$subreg_url = $registrator->url;
$subreg_user = $registrator->text1;
$subreg_password = decodePwd($registrator->text2);
$subreg_log = $registrator->check1;
if ($subreg_url and $subreg_user and $subreg_password) {
$subreg = new SUBREG;
$subreg->init($subreg_url,$subreg_user,$subreg_password,$subreg_log);
if ($privacy) {
$result = $subreg->updateDomainPrivacy($domain->domain, 1);
} else {
$result = $subreg->updateDomainPrivacy($domain->domain, 0);
}
mconnect();
if ($result) {
$error = "";
} else {
$error = $subreg->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else { $error = $_lang[DomainsErrorRegistratorUnknown]." ($registrator->type)"; }
} else { $error = $_lang[DomainsErrorProfileNotCheckedByAdmin]; }
} else { $error = $_lang[DomainsErrorProfileNotFilled]." (".$GLOBALerror.")"; }
} else { $error = $_lang[DomainsErrorUserNotFound]; }
} else { $error = $_lang[DomainsErrorRegistratorInactive]; }
} else { $error = $_lang[DomainsErrorNoRegistrator]; }
} else { $error = $_lang[DomainsErrorZoneNotFound]; }
} else { $error = $_lang[DomainsErrorDomainOrdersNotFound]." ID #$domain_id."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически изменить Privacy Protection для домена $domain->domain через $registrator->name по следующей причине:nn$errornnВам необходимо сделать это вручную!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка изменения Privacy Protection для домена";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function updateDomainTransferRequest($domain_id, $approve, $sendErrorEmail = 1) {
global $GLOBALerror, $_lang, $full_home_path, $onlinenicDomainTypes, $nicruService, $nicruTemplate, $startedRegion, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$profileId = $domain->profileId;
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($domain->autoregby) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->active) {
$registratorId = $registrator->id;
$user = GetUserById($domain->uid);
if ($user->id) {
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$isR = 1; $chkProfile = "max";
} else {
$isD = 1;
$chkProfile = GetSetting("checkprofiletype");
if (mb_strtolower($zone->zone) == "pp.ua") { $rF[] = "mobile"; }
}
if (checkProfile($chkProfile, $user->id, $profileId, $rF)) {
if (mb_strtolower($zone->zone) == "ru") { $isR = 1; $isD=""; } else { $isD = 1; $isR="";}
if (checkProfileByAdmin($user->id, $profileId)) {
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$profile = GetUserProfileByUserId($localContactUser->id, $zone->localContact);
} else {
$profile = GetUserProfileByUserId($user->id, $profileId);
}
if ($registrator->type != "started" and $registrator->type != "r01" and $registrator->type != "rootpanel") {
$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 ($registrator->type == "hostmasterepp") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($registrator->text2);
$hostmaster_ssl = $registrator->text3;
$hostmaster_log = $registrator->check1;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTEREPP;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password,$hostmaster_ssl,$hostmaster_log);
if ($approve) {
$result = $hostmaster->approveTransfer($domain->domain);
} else {
$result = $hostmaster->rejectTransfer($domain->domain);
}
if ($result) {
$error = "";
} else {
$error = $hostmaster->error;
}
$hostmaster->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "nicdpua") {
$nicdpua_url = $registrator->url;
$nicdpua_port = $registrator->port;
$nicdpua_user = $registrator->text1;
$nicdpua_password = decodePwd($registrator->text2);
$nicdpua_ssl = $registrator->text3;
$nicdpua_log = $registrator->check1;
if ($nicdpua_url and $nicdpua_port and $nicdpua_user and $nicdpua_password) {
$nicdpua = new NICDPUA;
$nicdpua->init($nicdpua_url,$nicdpua_port,$nicdpua_user,$nicdpua_password,$nicdpua_ssl,$nicdpua_log);
if ($approve) {
$result = $nicdpua->approveTransfer($domain->domain);
} else {
$result = $nicdpua->rejectTransfer($domain->domain);
}
if ($result) {
$error = "";
} else {
$error = $nicdpua->error;
}
$nicdpua->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "ppua") {
$ppua_url = $registrator->url;
$ppua_port = $registrator->port;
$ppua_user = $registrator->text1;
$ppua_password = decodePwd($registrator->text2);
$ppua_log = $registrator->check1;
if ($ppua_url and $ppua_port and $ppua_user and $ppua_password) {
$ppua = new PPUA;
$ppua->init($ppua_url,$ppua_port,$ppua_user,$ppua_password,$ppua_log);
if ($approve) {
$result = $ppua->approveTransfer($domain->domain);
} else {
$result = $ppua->rejectTransfer($domain->domain);
}
mconnect();
if ($result) {
$error = "";
} else {
$error = $ppua->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else { $error = $_lang[DomainsErrorRegistratorUnknown]." ($registrator->type)"; }
} else { $error = $_lang[DomainsErrorProfileNotCheckedByAdmin]; }
} else { $error = $_lang[DomainsErrorProfileNotFilled]." (".$GLOBALerror.")"; }
} else { $error = $_lang[DomainsErrorUserNotFound]; }
} else { $error = $_lang[DomainsErrorRegistratorInactive]; }
} else { $error = $_lang[DomainsErrorNoRegistrator]; }
} else { $error = $_lang[DomainsErrorZoneNotFound]; }
} else { $error = $_lang[DomainsErrorDomainOrdersNotFound]." ID #$domain_id."; }
$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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function updateDomainAuthCode($domain_id, $authcode, $sendErrorEmail = 1) {
global $GLOBALerror, $_lang, $full_home_path, $onlinenicDomainTypes, $nicruService, $nicruTemplate, $startedRegion, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$profileId = $domain->profileId;
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($domain->autoregby) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->active) {
$registratorId = $registrator->id;
$user = GetUserById($domain->uid);
if ($user->id) {
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$isR = 1; $chkProfile = "max";
} else {
$isD = 1;
$chkProfile = GetSetting("checkprofiletype");
if (mb_strtolower($zone->zone) == "pp.ua") { $rF[] = "mobile"; }
}
if (checkProfile($chkProfile, $user->id, $profileId, $rF)) {
if (mb_strtolower($zone->zone) == "ru") { $isR = 1; $isD=""; } else { $isD = 1; $isR="";}
if (checkProfileByAdmin($user->id, $profileId)) {
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$profile = GetUserProfileByUserId($localContactUser->id, $zone->localContact);
} else {
$profile = GetUserProfileByUserId($user->id, $profileId);
}
if ($registrator->type != "started" and $registrator->type != "r01" and $registrator->type != "rootpanel") {
$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 ($registrator->type == "hostmasterepp") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($registrator->text2);
$hostmaster_ssl = $registrator->text3;
$hostmaster_log = $registrator->check1;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTEREPP;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password,$hostmaster_ssl,$hostmaster_log);
$result = $hostmaster->updateAuthInfoDomain($domain->domain, $authcode);
if ($result) {
$error = "";
} else {
$error = $hostmaster->error;
}
$hostmaster->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "nicdpua") {
$nicdpua_url = $registrator->url;
$nicdpua_port = $registrator->port;
$nicdpua_user = $registrator->text1;
$nicdpua_password = decodePwd($registrator->text2);
$nicdpua_ssl = $registrator->text3;
$nicdpua_log = $registrator->check1;
if ($nicdpua_url and $nicdpua_port and $nicdpua_user and $nicdpua_password) {
$nicdpua = new NICDPUA;
$nicdpua->init($nicdpua_url,$nicdpua_port,$nicdpua_user,$nicdpua_password,$nicdpua_ssl,$nicdpua_log);
$result = $nicdpua->updateAuthInfoDomain($domain->domain, $authcode);
if ($result) {
$error = "";
} else {
$error = $nicdpua->error;
}
$nicdpua->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else { $error = $_lang[DomainsErrorRegistratorUnknown]." ($registrator->type)"; }
} else { $error = $_lang[DomainsErrorProfileNotCheckedByAdmin]; }
} else { $error = $_lang[DomainsErrorProfileNotFilled]." (".$GLOBALerror.")"; }
} else { $error = $_lang[DomainsErrorUserNotFound]; }
} else { $error = $_lang[DomainsErrorRegistratorInactive]; }
} else { $error = $_lang[DomainsErrorNoRegistrator]; }
} else { $error = $_lang[DomainsErrorZoneNotFound]; }
} else { $error = $_lang[DomainsErrorDomainOrdersNotFound]." ID #$domain_id."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически изменить auth-code для домена $domain->domain через $registrator->name по следующей причине:nn$errornnВам необходимо сделать это вручную!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка изменения auth-code для домена";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function suspendDomain($domain_id, $suspend, $sendErrorEmail = 1) {
global $GLOBALerror, $_lang, $full_home_path, $onlinenicDomainTypes, $nicruService, $nicruTemplate, $startedRegion, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$profileId = $domain->profileId;
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($domain->autoregby) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->active) {
$registratorId = $registrator->id;
$user = GetUserById($domain->uid);
if ($user->id) {
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$isR = 1; $chkProfile = "max";
} else {
$isD = 1;
$chkProfile = GetSetting("checkprofiletype");
if (mb_strtolower($zone->zone) == "pp.ua") { $rF[] = "mobile"; }
}
if (checkProfile($chkProfile, $user->id, $profileId, $rF)) {
if (mb_strtolower($zone->zone) == "ru") { $isR = 1; $isD=""; } else { $isD = 1; $isR="";}
if (checkProfileByAdmin($user->id, $profileId)) {
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$profile = GetUserProfileByUserId($localContactUser->id, $zone->localContact);
} else {
$profile = GetUserProfileByUserId($user->id, $profileId);
}
if ($registrator->type != "started" and $registrator->type != "r01" and $registrator->type != "rootpanel") {
$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 ($registrator->type == "hostmasterepp") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($registrator->text2);
$hostmaster_ssl = $registrator->text3;
$hostmaster_log = $registrator->check1;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTEREPP;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password,$hostmaster_ssl,$hostmaster_log);
if ($suspend) {
$result = $hostmaster->suspendDomain($domain->domain);
} else {
$result = $hostmaster->unSuspendDomain($domain->domain);
}
if ($result) {
$error = "";
} else {
$error = $hostmaster->error;
}
$hostmaster->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "nicdpua") {
$nicdpua_url = $registrator->url;
$nicdpua_port = $registrator->port;
$nicdpua_user = $registrator->text1;
$nicdpua_password = decodePwd($registrator->text2);
$nicdpua_ssl = $registrator->text3;
$nicdpua_log = $registrator->check1;
if ($nicdpua_url and $nicdpua_port and $nicdpua_user and $nicdpua_password) {
$nicdpua = new NICDPUA;
$nicdpua->init($nicdpua_url,$nicdpua_port,$nicdpua_user,$nicdpua_password,$nicdpua_ssl,$nicdpua_log);
if ($suspend) {
$result = $nicdpua->suspendDomain($domain->domain);
} else {
$result = $nicdpua->unSuspendDomain($domain->domain);
}
if ($result) {
$error = "";
} else {
$error = $nicdpua->error;
}
$nicdpua->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else { $error = $_lang[DomainsErrorRegistratorUnknown]." ($registrator->type)"; }
} else { $error = $_lang[DomainsErrorProfileNotCheckedByAdmin]; }
} else { $error = $_lang[DomainsErrorProfileNotFilled]." (".$GLOBALerror.")"; }
} else { $error = $_lang[DomainsErrorUserNotFound]; }
} else { $error = $_lang[DomainsErrorRegistratorInactive]; }
} else { $error = $_lang[DomainsErrorNoRegistrator]; }
} else { $error = $_lang[DomainsErrorZoneNotFound]; }
} else { $error = $_lang[DomainsErrorDomainOrdersNotFound]." ID #$domain_id."; }
$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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function deleteDomain($domain_id, $sendErrorEmail = 1) {
global $GLOBALerror, $_lang, $full_home_path, $onlinenicDomainTypes, $nicruService, $nicruTemplate, $startedRegion, $dbhost, $dbuser, $dbpass, $dbname, $ip;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$profileId = $domain->profileId;
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($domain->autoregby) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->active) {
$registratorId = $registrator->id;
$user = GetUserById($domain->uid);
if ($user->id) {
if (preg_match("/.{0,1}[ru|su|рф]$/ui",$zone->zone)) {
$isR = 1; $chkProfile = "max";
} else {
$isD = 1;
$chkProfile = GetSetting("checkprofiletype");
if (mb_strtolower($zone->zone) == "pp.ua") { $rF[] = "mobile"; }
}
if (checkProfile($chkProfile, $user->id, $profileId, $rF)) {
if (mb_strtolower($zone->zone) == "ru") { $isR = 1; $isD=""; } else { $isD = 1; $isR="";}
if (checkProfileByAdmin($user->id, $profileId)) {
$localContactUser = GetUserByLogin(GetSetting("localContactUser"));
if ($localContactUser->id and $zone->localContact and $domain->localContact) {
$profile = GetUserProfileByUserId($localContactUser->id, $zone->localContact);
} else {
$profile = GetUserProfileByUserId($user->id, $profileId);
}
if ($registrator->type != "started" and $registrator->type != "r01" and $registrator->type != "rootpanel") {
$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 ($registrator->type == "hostmasterepp") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = decodePwd($registrator->text2);
$hostmaster_ssl = $registrator->text3;
$hostmaster_log = $registrator->check1;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTEREPP;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password,$hostmaster_ssl,$hostmaster_log);
$result = $hostmaster->deleteDomain($domain->domain);
if ($result) {
$error = "";
} else {
$error = $hostmaster->error;
}
$hostmaster->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "nicdpua") {
$nicdpua_url = $registrator->url;
$nicdpua_port = $registrator->port;
$nicdpua_user = $registrator->text1;
$nicdpua_password = decodePwd($registrator->text2);
$nicdpua_ssl = $registrator->text3;
$nicdpua_log = $registrator->check1;
if ($nicdpua_url and $nicdpua_port and $nicdpua_user and $nicdpua_password) {
$nicdpua = new NICDPUA;
$nicdpua->init($nicdpua_url,$nicdpua_port,$nicdpua_user,$nicdpua_password,$nicdpua_ssl,$nicdpua_log);
$result = $nicdpua->deleteDomain($domain->domain);
if ($result) {
$error = "";
} else {
$error = $nicdpua->error;
}
$nicdpua->logout();
mconnect();
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else { $error = $_lang[DomainsErrorRegistratorUnknown]." ($registrator->type)"; }
} else { $error = $_lang[DomainsErrorProfileNotCheckedByAdmin]; }
} else { $error = $_lang[DomainsErrorProfileNotFilled]." (".$GLOBALerror.")"; }
} else { $error = $_lang[DomainsErrorUserNotFound]; }
} else { $error = $_lang[DomainsErrorRegistratorInactive]; }
} else { $error = $_lang[DomainsErrorNoRegistrator]; }
} else { $error = $_lang[DomainsErrorZoneNotFound]; }
} else { $error = $_lang[DomainsErrorDomainOrdersNotFound]." ID #$domain_id."; }
$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);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function createDomainZoneAtServer($domain_id, $ns1, $ns2, $ns3, $ns4, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $dbhost, $dbuser, $dbpass, $dbname;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($zone->enableCreateZone == "1" and !$domain->dnsServerIsShell) {
// прописываем с помощью запуска скрипта
$server->id = "shellscript";
$command = $zone->createZoneScript;
$reply = $zone->createZoneScriptReply;
if ($command) {
$command = preg_replace("/{domain}/ui","$domain->domain",$command);
$command = preg_replace("/{ns1}/ui","$ns1",$command);
$command = preg_replace("/{ns2}/ui","$ns2",$command);
$command = preg_replace("/{ns3}/ui","$ns3",$command);
$command = preg_replace("/{ns4}/ui","$ns4",$command);
exec("$command", $result, $resultstatus);
mconnect();
if ($resultstatus) { $error = "Не удалось выполнить команду $command для создания DNS-зоны."; }
else {
$result = @join("",$result);
if (!$reply or preg_match("/".$reply."/ui",$result)) {
@mysql_query("update orders_domains set defaultNSFlag='0',dnsServerIsShell='1' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
}
else { $error = "Биллингом был получен неудовлетворительный ответ для команды $command"; }
}
}
else { $error = "В доменной зоне ID # $zone->id, $zone->zone не указан скрипт для создания DNS-зоны."; }
}
else if ($zone->enableCreateZone == "2" and !$domain->dnsServerId) {
// прописываем на сервере
$server = GetServers($zone->createZoneServer);
if ($server->id) {
if ($server->type and $server->ip and $server->user and $server->password and $server->userip) {
if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
$nss = "$ns1.%20$ns2.";
if ($ns3) { $nss .= "%20$ns3.";}
if ($ns4) { $nss .= "%20$ns4.";}
$addDomainResult = $autoisp->addDomain($domain->domain,$server->userip,$nss,"mail","$zone->createZoneServerLogin","","");
mconnect();
if ($addDomainResult) {
@mysql_query("update orders_domains set defaultNSFlag='0',dnsServerId='$server->id' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $autoisp->error;
}
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if (!$da->error) {
$parkResult = $da->add_domain_pointer($zone->createZoneServerLogin,$domain->domain);
if ($parkResult) {
mconnect();
@mysql_query("update orders_domains set defaultNSFlag='0',dnsServerId='$server->id',dnsServerValue='$zone->createZoneServerLogin' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$da->logOut();
$error = "";
} else {
$error = $da->error;
$da->logOut();
}
} else {
$error = $da->error;
$da->logOut();
}
mconnect();
}
else { $error = "Тип серверов $server->type не поддерживается для создания DNS-зон."; }
} else { $error = "Сервер ID # $server->id настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Сервер ID # $zone->createZoneServer не найден."; }
} else { $error = "Для доменной зоны не настроено создание DNS-зоны на сервере, либо DNS-зона уже создана."; }
} else { $error = "Не найдена доменная зона."; }
} else { $error = "Не найден заказ на домен ID # $domain_id."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог создать DNS-зону для домена $domain->domain на сервере ID # $server->id по следующей причине:nn$errornnВам необходимо создать DNS-зону для домена вручную!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка создания DNS-зоны для домена";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function deleteDomainZoneAtServer($domain_id, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $dbhost, $dbuser, $dbpass, $dbname;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
if ($domain->dnsServerId) {
$server = GetServers($domain->dnsServerId);
if ($server->id) {
if ($server->type and $server->ip and $server->user and $server->password and $server->userip) {
if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
$deleteDomainResult = $autoisp->deleteDomain($domain->domain);
mconnect();
if ($deleteDomainResult) {
@mysql_query("update orders_domains set dnsServerId='' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $autoisp->error;
}
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if (!$da->error) {
$deleteParkResult = $da->delete_domain_pointer($domain->dnsServerValue,$domain->domain);
if ($deleteParkResult) {
mconnect();
@mysql_query("update orders_domains set dnsServerId='',dnsServerValue='' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$da->logOut();
$error = "";
} else {
$error = $da->error;
$da->logOut();
}
} else {
$error = $da->error;
$da->logOut();
}
mconnect();
}
else { $error = "Тип серверов $server->type не поддерживается."; }
} else { $error = "Сервер ID # $server->id настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Сервер ID # $domain->dnsServerId не найден."; }
} else { $error = "Домен не привязан ни к одному из серверов."; }
} else { $error = "Не найден заказ на домен ID # $domain_id."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически удалить DNS-зону для домена $domain->domain на сервере ID # $server->id по следующей причине:nn$errornnВам необходимо удалить DNS-зону для домена вручную!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка удаления DNS-зоны для домена";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function getDNSRecordsAtServer($domain_id, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $dbhost, $dbuser, $dbpass, $dbname;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
if ($domain->dnsServerId) {
$server = GetServers($domain->dnsServerId);
if ($server->id) {
if ($server->type and $server->ip and $server->user and $server->password and $server->userip) {
if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
$result = $autoisp->getDNS($domain->domain);
mconnect();
if ($result) {
return $result;
} else {
$error = $autoisp->error;
}
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if (!$da->error) {
$result = $da->getDNS($domain->dnsServerValue,$domain->domain);
if ($result) {
$da->logOut();
mconnect();
return $result;
} else {
$error = $da->error;
$da->logOut();
}
} else {
$error = $da->error;
$da->logOut();
}
mconnect();
}
else { $error = "Тип серверов $server->type не поддерживается."; }
} else { $error = "Сервер ID # $server->id настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Сервер ID # $domain->dnsServerId не найден."; }
} else { $error = "Домен не привязан ни к одному из серверов."; }
} else { $error = "Не найден заказ на домен ID # $domain_id."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог получить DNS-записи для домена $domain->domain на сервере ID # $server->id по следующей причине:nn$error";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка получения DNS-записей для домена";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function updateDNSRecordsAtServer($domain_id, $dns, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $dbhost, $dbuser, $dbpass, $dbname;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
if ($domain->dnsServerId) {
$server = GetServers($domain->dnsServerId);
if ($server->id) {
if ($server->type and $server->ip and $server->user and $server->password and $server->userip) {
if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
$result = $autoisp->updateDNS($domain->domain,$dns);
mconnect();
if (!$result) {
$error = $autoisp->error;
}
} else { $error = "Тип серверов $server->type не поддерживается."; }
} else { $error = "Сервер ID # $server->id настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Сервер ID # $domain->dnsServerId не найден."; }
} else { $error = "Домен не привязан ни к одному из серверов."; }
} else { $error = "Не найден заказ на домен ID # $domain_id."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог изменить DNS-записи для домена $domain->domain на сервере ID # $server->id по следующей причине:nn$error";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка изменения DNS-записей для домена";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function createDNSRecordsAtServer($domain_id, $name, $type, $addr, $prio, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $dbhost, $dbuser, $dbpass, $dbname;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
if ($domain->dnsServerId) {
$server = GetServers($domain->dnsServerId);
if ($server->id) {
if ($server->type and $server->ip and $server->user and $server->password and $server->userip) {
if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
$result = $autoisp->createDNS($domain->domain,$name,$type,$addr,$prio);
mconnect();
if (!$result) {
$error = $autoisp->error;
}
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if (!$da->error) {
$result = $da->createDNS($domain->dnsServerValue,$domain->domain,$name,$type,$addr,$prio);
if (!$result) {
$error = $da->error;
}
$da->logOut();
} else {
$error = $da->error;
$da->logOut();
}
mconnect();
}
else { $error = "Тип серверов $server->type не поддерживается."; }
} else { $error = "Сервер ID # $server->id настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Сервер ID # $domain->dnsServerId не найден."; }
} else { $error = "Домен не привязан ни к одному из серверов."; }
} else { $error = "Не найден заказ на домен ID # $domain_id."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог изменить DNS-записи для домена $domain->domain на сервере ID # $server->id по следующей причине:nn$error";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка изменения DNS-записей для домена";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function deleteDNSRecordsAtServer($domain_id, $key, $key2 = '', $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $dbhost, $dbuser, $dbpass, $dbname;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$domain->domain = trim($domain->domain);
if ($domain->dnsServerId) {
$server = GetServers($domain->dnsServerId);
if ($server->id) {
if ($server->type and $server->ip and $server->user and $server->password and $server->userip) {
if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,decodePwd($server->password),$server->folder);
$result = $autoisp->deleteDNS($domain->domain,$key);
mconnect();
if (!$result) {
$error = $autoisp->error;
}
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,decodePwd($server->password));
if (!$da->error) {
$result = $da->deleteDNS($domain->dnsServerValue,$domain->domain,$key,$key2);
if (!$result) {
$error = $da->error;
}
$da->logOut();
} else {
$error = $da->error;
$da->logOut();
}
mconnect();
}
else { $error = "Тип серверов $server->type не поддерживается."; }
} else { $error = "Сервер ID # $server->id настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Сервер ID # $domain->dnsServerId не найден."; }
} else { $error = "Домен не привязан ни к одному из серверов."; }
} else { $error = "Не найден заказ на домен ID # $domain_id."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог удалить DNS-запись для домена $domain->domain на сервере ID # $server->id по следующей причине:nn$error";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка удаления DNS-записи для домена";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
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,$addon='') {
global $_lang;
head('utf-8',$_lang[Error]);
print "<H1 class=pagetitle>".$_lang[Error]."</H1><hr class=hr>";
print "<font color=red>$err</font>";
print "<BR>".$addon;
foot('utf-8');
}
function createFaktura($fid, $billid, $type, $orgName='', $orgPhone='', $isSchetFaktura='') {
// $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) {
if ($isSchetFaktura) {
$f = @mysql_query("select * from kvitancii_faktura where active='1' and enableSchetFaktura='1'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$f = @mysql_query("select * from kvitancii_faktura where active='1' and 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 ($isSchetFaktura) {
if ($f->template_faktura_pdf) { $faktura = htmlDecode($f->template_faktura_pdf); } else { $faktura = GetTpl("tpl_faktura_faktura_pdf", $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);
$money_total = $money_one * $bill->host_srok;
if ($f->nds > 0) {
if ($f->currency == "UAH" and $f->ndstype != "out" and $f->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$f->nds,2);
$ndssumma_total = round($money_total/100*$f->nds,2);
}
if ($f->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_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);
$money_total = $money_one;
if ($f->nds > 0) {
if ($f->currency == "UAH" and $f->ndstype != "out" and $f->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$f->nds,2);
$ndssumma_total = round($money_total/100*$f->nds,2);
}
if ($f->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$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_total,$rowToSave);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$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;
if ($f->nds > 0) {
if ($f->currency == "UAH" and $f->ndstype != "out" and $f->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$f->nds,2);
$ndssumma_total = round($money_total/100*$f->nds,2);
}
if ($f->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_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);
$money_total = $money_one;
if ($f->nds > 0) {
if ($f->currency == "UAH" and $f->ndstype != "out" and $f->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$f->nds,2);
$ndssumma_total = round($money_total/100*$f->nds,2);
}
if ($f->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$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_total,$rowToSave);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$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);
$money_total = $money_one * ($bill->domain_srok/12);
if ($f->nds > 0) {
if ($f->currency == "UAH" and $f->ndstype != "out" and $f->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$f->nds,2);
$ndssumma_total = round($money_total/100*$f->nds,2);
}
if ($f->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_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);
$money_total = $money_one * $bill->shop_srok;
}
if ($f->nds > 0) {
if ($f->currency == "UAH" and $f->ndstype != "out" and $f->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$f->nds,2);
$ndssumma_total = round($money_total/100*$f->nds,2);
}
if ($f->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_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);
$money_total = $money_one;
if ($f->nds > 0) {
if ($f->currency == "UAH" and $f->ndstype != "out" and $f->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$f->nds,2);
$ndssumma_total = round($money_total/100*$f->nds,2);
}
if ($f->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$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_total,$rowToSave);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$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);
$money_total = $money_one;
if ($f->nds > 0) {
if ($f->currency == "UAH" and $f->ndstype != "out" and $f->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$f->nds,2);
$ndssumma_total = round($money_total/100*$f->nds,2);
}
if ($f->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$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_total,$rowToSave);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
$rowsToSave = @join("n",$rowsToSave);
$faktura = str_replace("<!--RowEnd-->","<!--RowEnd-->".$rowsToSave,$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("{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";}
$dtCreated = mb_split("-",$bill->created); $dtY = $dtCreated[0]; $dtM = intval($dtCreated[1]); $dtD = intval($dtCreated[2]);
$faktura = str_replace("{date}",$dtD." ".$_lang[monthR][$dtM]." ".$dtY." ".$_lang[FakturaGoda],$faktura);
if ($f->nds > 0) {
if ($f->currency == "UAH" and $f->ndstype != "out" and $f->nds == 20) {
$ndssumma = round($money_faktura/6,2);
} else {
$ndssumma = round($money_faktura/100*$f->nds,2);
}
if ($f->ndstype == "out") {
$money_faktura_beznds = $money_faktura;
$money_faktura = round($money_faktura + $ndssumma, 2);
} else {
$money_faktura_beznds = round($money_faktura - $ndssumma, 2);
$money_faktura = $money_faktura;
}
$faktura = str_replace("{ndsval}",$f->nds,$faktura);
$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 {
$money_faktura_beznds = $money_faktura;
$faktura = str_replace("{ndsval}","0",$faktura);
$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 = str_replace("{summa}",$money_faktura,$faktura);
$faktura = str_replace("{summabeznds}",$money_faktura_beznds,$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
if ($isSchetFaktura) {
$dompdf->stream("faktura.pdf", array("Attachment" => 1));
} else {
$dompdf->stream("schet.pdf", array("Attachment" => 1));
}
}
else if ($type == "2") {
// return filename
if ($isSchetFaktura) {
$filename = $full_home_path."/_roottemp/"."faktura_".$bill->uid."_".$bill->id.".pdf";
} else {
$filename = $full_home_path."/_roottemp/"."schet_".$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);
$profile = GetUserProfileByUserId($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) {
$q = @mysql_query("select * from kvitancii_db where kvid='$kv->id' and billid='$bill->id' and uid='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if (@mysql_num_rows($q) > 0) {
$q = @mysql_fetch_object($q);
$kvtpl = htmlDecode($q->html);
$kvtplpdf = htmlDecode($q->pdf);
}
else {
@mysql_query("INSERT INTO kvitancii_db (uid,billid,kvid,datecreated) VALUES('$user->id','$bill->id','$kv->id',NOW())") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$kvdbid = @mysql_insert_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 ($kv->template) { $kvtpl = htmlDecode($kv->template); } else { $kvtpl = GetTpl("tpl_sberbank", $user->lang); $kvtpl = $kvtpl[template]; }
if ($kv->template_pdf) { $kvtplpdf = htmlDecode($kv->template_pdf); } else { $kvtplpdf = GetTpl("tpl_sberbank_pdf", $user->lang); $kvtplpdf = $kvtplpdf[template]; }
if ($kv->lang) {$kvLang=$kv->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);
preg_match("/<!--RowBegin-->(.+)<!--RowEnd-->/isu",$kvtpl,$arr);
preg_match("/<!--RowBegin-->(.+)<!--RowEnd-->/isu",$kvtplpdf,$arrPdf);
$itemsCnt=0;
$uslugaTxt = "";
$rowsToSave = array();
$rowsToSavePdf = array();
if ($arr[1] or $arrPdf[1]) {
$money_kv = 0;
}
if ($bill->host_id and !$bill->newtarif and !$bill->newaddons and !$bill->newserver and !$bill->newslots) {
$order = GetOrderById($bill->host_id);
$tarif = GetTarifById($order->tarif);
$hostType = $tarif->vid;
$uslugaTxt .= $_lang[FakturaHost][$hostType]." ".$tarif->name.", ".$_lang[FakturaPrefixSrok]." ".$bill->host_srok." ".$_lang[OrderSokraschenieMonth];
if ($arr[1] or $arrPdf[1]) {
$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);
$money_total = $money_one * $bill->host_srok;
$money_kv += $money_total;
if ($kv->nds > 0) {
if ($kv->currency == "UAH" and $kv->ndstype != "out" and $kv->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$kv->nds,2);
$ndssumma_total = round($money_total/100*$kv->nds,2);
}
if ($kv->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$itemsCnt++;
if ($arr[1]) {
$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($arrPdf[1]) {
$rowToSavePdf = $arrPdf[1];
$rowToSavePdf = str_replace("{pp}",$itemsCnt.".",$rowToSavePdf);
$rowToSavePdf = str_replace("{usluga}",$_lang[FakturaHost][$hostType]." ".$tarif->name,$rowToSavePdf);
$rowToSavePdf = str_replace("{edinica}",$_lang[OrderSokraschenieMonth],$rowToSavePdf);
$rowToSavePdf = str_replace("{count}",$bill->host_srok,$rowToSavePdf);
$rowToSavePdf = str_replace("{cena}",$money_one,$rowToSavePdf);
$rowToSavePdf = str_replace("{summa_one}",$money_total,$rowToSavePdf);
$rowToSavePdf = str_replace("{cena_beznds}",$money_one_beznds,$rowToSavePdf);
$rowToSavePdf = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSavePdf);
$rowToSavePdf = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSavePdf);
$rowToSavePdf = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSavePdf);
$rowsToSavePdf[] = $rowToSavePdf;
}
}
if ($bill->money_addons) {
$uslugaTxt .= " + ".$_lang[FakturaAddon]." ".$order->id;
if ($arr[1] or $arrPdf[1]) {
$money_one = $bill->money_addons*$currency->koeficient; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$money_total = $money_one;
$money_kv += $money_total;
if ($kv->nds > 0) {
if ($kv->currency == "UAH" and $kv->ndstype != "out" and $kv->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$kv->nds,2);
$ndssumma_total = round($money_total/100*$kv->nds,2);
}
if ($kv->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$itemsCnt++;
if ($arr[1]) {
$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_total,$rowToSave);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($arrPdf[1]) {
$rowToSavePdf = $arrPdf[1];
$rowToSavePdf = str_replace("{pp}",$itemsCnt.".",$rowToSavePdf);
$rowToSavePdf = str_replace("{usluga}",$_lang[FakturaAddon]." ".$order->id,$rowToSavePdf);
$rowToSavePdf = str_replace("{edinica}",$_lang[FakturaSokraschenieShtuka],$rowToSavePdf);
$rowToSavePdf = str_replace("{count}","1",$rowToSavePdf);
$rowToSavePdf = str_replace("{cena}",$money_one,$rowToSavePdf);
$rowToSavePdf = str_replace("{summa_one}",$money_total,$rowToSavePdf);
$rowToSavePdf = str_replace("{cena_beznds}",$money_one_beznds,$rowToSavePdf);
$rowToSavePdf = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSavePdf);
$rowToSavePdf = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSavePdf);
$rowToSavePdf = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSavePdf);
$rowsToSavePdf[] = $rowToSavePdf;
}
}
}
}
else if ($bill->host_id and $bill->newtarif) {
$order = GetOrderById($bill->host_id);
if ($uslugaTxt) { $uslugaTxt .= " + "; }
$uslugaTxt .= $_lang[FakturaChangeTarif]." ".$order->id;
if ($arr[1] or $arrPdf[1]) {
$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;
$money_kv += $money_total;
if ($kv->nds > 0) {
if ($kv->currency == "UAH" and $kv->ndstype != "out" and $kv->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$kv->nds,2);
$ndssumma_total = round($money_total/100*$kv->nds,2);
}
if ($kv->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$itemsCnt++;
if ($arr[1]) {
$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($arrPdf[1]) {
$rowToSavePdf = $arrPdf[1];
$rowToSavePdf = str_replace("{pp}",$itemsCnt.".",$rowToSavePdf);
$rowToSavePdf = str_replace("{usluga}",$_lang[FakturaChangeTarif]." ".$order->id,$rowToSavePdf);
$rowToSavePdf = str_replace("{edinica}",$_lang[FakturaSokraschenieShtuka],$rowToSavePdf);
$rowToSavePdf = str_replace("{count}","1",$rowToSavePdf);
$rowToSavePdf = str_replace("{cena}",$money_one,$rowToSavePdf);
$rowToSavePdf = str_replace("{summa_one}",$money_total,$rowToSavePdf);
$rowToSavePdf = str_replace("{cena_beznds}",$money_one_beznds,$rowToSavePdf);
$rowToSavePdf = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSavePdf);
$rowToSavePdf = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSavePdf);
$rowToSavePdf = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSavePdf);
$rowsToSavePdf[] = $rowToSavePdf;
}
}
}
else if ($bill->host_id and $bill->newaddons) {
$order = GetOrderById($bill->host_id);
if ($uslugaTxt) { $uslugaTxt .= " + "; }
$uslugaTxt .= $_lang[FakturaAddon]." ".$order->id;
if ($arr[1] or $arrPdf[1]) {
$money_one = $bill->money_addons*$currency->koeficient; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$money_total = $money_one;
$money_kv += $money_total;
if ($kv->nds > 0) {
if ($kv->currency == "UAH" and $kv->ndstype != "out" and $kv->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$kv->nds,2);
$ndssumma_total = round($money_total/100*$kv->nds,2);
}
if ($kv->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$itemsCnt++;
if ($arr[1]) {
$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_total,$rowToSave);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($arrPdf[1]) {
$rowToSave = $arrPdf[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_total,$rowToSave);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSavePdf[] = $rowToSave;
}
}
}
else if ($bill->host_id and $bill->newserver) {
$order = GetOrderById($bill->host_id);
if ($uslugaTxt) { $uslugaTxt .= " + "; }
$uslugaTxt .= $_lang[FakturaNewServer]." ".$order->id;
if ($arr[1] or $arrPdf[1]) {
$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;
$money_kv += $money_total;
if ($kv->nds > 0) {
if ($kv->currency == "UAH" and $kv->ndstype != "out" and $kv->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$kv->nds,2);
$ndssumma_total = round($money_total/100*$kv->nds,2);
}
if ($kv->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$itemsCnt++;
if ($arr[1]) {
$rowToSave = $arr[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$_lang[FakturaNewServer]." ".$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($arrPdf[1]) {
$rowToSave = $arrPdf[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$_lang[FakturaNewServer]." ".$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSavePdf[] = $rowToSave;
}
}
}
else if ($bill->host_id and $bill->newslots) {
$order = GetOrderById($bill->host_id);
if ($uslugaTxt) { $uslugaTxt .= " + "; }
$uslugaTxt .= $_lang[FakturaNewSlots]." ".$order->id;
if ($arr[1] or $arrPdf[1]) {
$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;
$money_kv += $money_total;
if ($kv->nds > 0) {
if ($kv->currency == "UAH" and $kv->ndstype != "out" and $kv->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$kv->nds,2);
$ndssumma_total = round($money_total/100*$kv->nds,2);
}
if ($kv->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$itemsCnt++;
if ($arr[1]) {
$rowToSave = $arr[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$_lang[FakturaNewSlots]." ".$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($arrPdf[1]) {
$rowToSave = $arrPdf[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$_lang[FakturaNewSlots]." ".$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSavePdf[] = $rowToSave;
}
}
}
if ($bill->domain_id) {
$order = GetDomainById($bill->domain_id);
if ($uslugaTxt) { $uslugaTxt .= " + "; }
$uslugaTxt .= $_lang[FakturaDomain]." ".$order->domain.", ".$_lang[FakturaPrefixSrok]." ".($bill->domain_srok/12)." ".$_lang[OrderSokraschenieGod];
if ($arr[1] or $arrPdf[1]) {
$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);
$money_total = $money_one * ($bill->domain_srok/12);
$money_kv += $money_total;
if ($kv->nds > 0) {
if ($kv->currency == "UAH" and $kv->ndstype != "out" and $kv->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$kv->nds,2);
$ndssumma_total = round($money_total/100*$kv->nds,2);
}
if ($kv->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$itemsCnt++;
if ($arr[1]) {
$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($arrPdf[1]) {
$rowToSave = $arrPdf[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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSavePdf[] = $rowToSave;
}
}
}
if ($bill->shop_id) {
$order=GetOrderShopById($bill->shop_id);
$shopItem=GetShopItemById($order->item);
if ($shopItem->costtype == "one") {
if ($uslugaTxt) { $uslugaTxt .= " + "; }
$uslugaTxt .= $_lang[FakturaShop]." ".$shopItem->name;
$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 {
if ($uslugaTxt) { $uslugaTxt .= " + "; }
$uslugaTxt .= $_lang[FakturaShop]." ".$shopItem->name.", ".$_lang[FakturaPrefixSrok]." ".$bill->shop_srok." ".$_lang[OrderSokraschenieMonth];
$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);
$money_total = $money_one * $bill->shop_srok;
}
if ($arr[1] or $arrPdf[1]) {
$money_kv += $money_total;
if ($kv->nds > 0) {
if ($kv->currency == "UAH" and $kv->ndstype != "out" and $kv->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$kv->nds,2);
$ndssumma_total = round($money_total/100*$kv->nds,2);
}
if ($kv->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$itemsCnt++;
if ($arr[1]) {
$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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($arrPdf[1]) {
$rowToSave = $arrPdf[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);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSavePdf[] = $rowToSave;
}
}
}
if ($bill->addfunds) {
if ($uslugaTxt) { $uslugaTxt .= " + "; }
$uslugaTxt .= $_lang[FakturaAddFunds]." ".$user->id;
if ($arr[1] or $arrPdf[1]) {
$money_one = $bill->money*$currency->koeficient; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$money_total = $money_one;
$money_kv += $money_total;
if ($kv->nds > 0) {
if ($kv->currency == "UAH" and $kv->ndstype != "out" and $kv->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$kv->nds,2);
$ndssumma_total = round($money_total/100*$kv->nds,2);
}
if ($kv->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$itemsCnt++;
if ($arr[1]) {
$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_total,$rowToSave);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($arrPdf[1]) {
$rowToSave = $arrPdf[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_total,$rowToSave);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSavePdf[] = $rowToSave;
}
}
}
if (!$bill->addfunds and $bill->money) {
if ($uslugaTxt) { $uslugaTxt .= " + "; }
$uslugaTxt .= $bill->comment." (UID ".$user->id.")";
if ($arr[1] or $arrPdf[1]) {
$money_one = $bill->money*$currency->koeficient; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$money_total = $money_one;
$money_kv += $money_total;
if ($kv->nds > 0) {
if ($kv->currency == "UAH" and $kv->ndstype != "out" and $kv->nds == 20) {
$ndssumma_one = round($money_one/6,2);
$ndssumma_total = round($money_total/6,2);
} else {
$ndssumma_one = round($money_one/100*$kv->nds,2);
$ndssumma_total = round($money_total/100*$kv->nds,2);
}
if ($kv->ndstype == "out") {
$money_one_beznds = $money_one;
$money_one = round($money_one + $ndssumma_one, 2);
$money_total_beznds = $money_total;
$money_total = round($money_total + $ndssumma_total, 2);
} else {
$money_one_beznds = round($money_one - $ndssumma_one, 2);
$money_one = $money_one;
$money_total_beznds = round($money_total - $ndssumma_total, 2);
$money_total = $money_total;
}
} else {
$ndssumma_one = 0;
$ndssumma_total = 0;
$money_one_beznds = $money_one;
$money_total_beznds = $money_total;
}
$itemsCnt++;
if ($arr[1]) {
$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_total,$rowToSave);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($arrPdf[1]) {
$rowToSave = $arrPdf[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_total,$rowToSave);
$rowToSave = str_replace("{cena_beznds}",$money_one_beznds,$rowToSave);
$rowToSave = str_replace("{summa_one_beznds}",$money_total_beznds,$rowToSave);
$rowToSave = str_replace("{ndssumma_cena}",$ndssumma_one,$rowToSave);
$rowToSave = str_replace("{ndssumma_summa_one}",$ndssumma_total,$rowToSave);
$rowsToSavePdf[] = $rowToSave;
}
}
}
$kvtpl = preg_replace("/{usluga}/u",$uslugaTxt,$kvtpl); $kvtplpdf = preg_replace("/{usluga}/u",$uslugaTxt,$kvtplpdf);
if ($arr[1]) {
$rowsToSave = @join("n",$rowsToSave);
$kvtpl = str_replace("<!--RowEnd-->","<!--RowEnd-->".$rowsToSave,$kvtpl);
}
if ($arrPdf[1]) {
$rowsToSavePdf = @join("n",$rowsToSavePdf);
$kvtplpdf = str_replace("<!--RowEnd-->","<!--RowEnd-->".$rowsToSavePdf,$kvtplpdf);
}
$kvtpl = preg_replace("/{id}/u",$kvdbid,$kvtpl); $kvtplpdf = preg_replace("/{id}/u",$kvdbid,$kvtplpdf);
$kvtpl = preg_replace("/{firma}/u",$kv->orgname,$kvtpl); $kvtplpdf = preg_replace("/{firma}/u",$kv->orgname,$kvtplpdf);
$kvtpl = preg_replace("/{inn}/u",$kv->inn,$kvtpl); $kvtplpdf = preg_replace("/{inn}/u",$kv->inn,$kvtplpdf);
$kvtpl = preg_replace("/{kpp}/u",$kv->kpp,$kvtpl); $kvtplpdf = preg_replace("/{kpp}/u",$kv->kpp,$kvtplpdf);
$kvtpl = preg_replace("/{rs}/u",$kv->schet,$kvtpl); $kvtplpdf = preg_replace("/{rs}/u",$kv->schet,$kvtplpdf);
$kvtpl = preg_replace("/{bank}/u",$kv->bank,$kvtpl); $kvtplpdf = preg_replace("/{bank}/u",$kv->bank,$kvtplpdf);
$kvtpl = preg_replace("/{ks}/u",$kv->korschet,$kvtpl); $kvtplpdf = preg_replace("/{ks}/u",$kv->korschet,$kvtplpdf);
$kvtpl = preg_replace("/{bik}/u",$kv->bik,$kvtpl); $kvtplpdf = preg_replace("/{bik}/u",$kv->bik,$kvtplpdf);
$kvtpl = preg_replace("/{schet}/u",$sid,$kvtpl); $kvtplpdf = preg_replace("/{schet}/u",$sid,$kvtplpdf);
$kvtpl = preg_replace("/{num}/u",$sid,$kvtpl); $kvtplpdf = preg_replace("/{num}/u",$sid,$kvtplpdf);
$kvtpl = preg_replace("/{fio}/u",$profile->surname." ".$profile->name." ".$profile->otchestvo,$kvtpl); $kvtplpdf = preg_replace("/{fio}/u",$profile->surname." ".$profile->name." ".$profile->otchestvo,$kvtplpdf);
$kvtpl = preg_replace("/{clientfirma}/u",$profile->surname." ".$profile->name." ".$profile->otchestvo,$kvtpl); $kvtplpdf = preg_replace("/{clientfirma}/u",$profile->surname." ".$profile->name." ".$profile->otchestvo,$kvtplpdf);
$kvtpl = preg_replace("/{clientphone}/u",$profile->phone,$kvtpl); $kvtplpdf = preg_replace("/{clientphone}/u",$profile->phone,$kvtplpdf);
if ($kv->currency == "BYR") {$kv->currency = "RUB";}
$dtCreated = mb_split("-",$bill->created); $dtY = $dtCreated[0]; $dtM = intval($dtCreated[1]); $dtD = intval($dtCreated[2]);
$kvtpl = str_replace("{date}",$dtD." ".$_lang[monthR][$dtM]." ".$dtY." ".$_lang[FakturaGoda],$kvtpl); $kvtplpdf = str_replace("{date}",$dtD." ".$_lang[monthR][$dtM]." ".$dtY." ".$_lang[FakturaGoda],$kvtplpdf);
if ($kv->nds > 0) {
if ($kv->currency == "UAH" and $kv->ndstype != "out" and $kv->nds == 20) {
$ndssumma = round($money_kv/6,2);
} else {
$ndssumma = round($money_kv/100*$kv->nds,2);
}
if ($kv->ndstype == "out") {
$money_kv_beznds = $money_kv;
$money_kv = round($money_kv + $ndssumma, 2);
}
$kvtpl = str_replace("{ndsval}",$kv->nds,$kvtpl); $kvtplpdf = str_replace("{ndsval}",$kv->nds,$kvtplpdf);
$kvtpl = str_replace("{nds}",$_lang[FakturaSNds].":",$kvtpl); $kvtplpdf = str_replace("{nds}",$_lang[FakturaSNds].":",$kvtplpdf);
$kvtpl = preg_replace("/{ndssumma}/u",$ndssumma,$kvtpl); $kvtplpdf = preg_replace("/{ndssumma}/u",$ndssumma,$kvtplpdf);
$kvtpl = preg_replace("/{summapropis}/u",num2str($money_kv,$kv->currency,$kvLang).", ".$_lang[FakturaVTomChisleNds]." ".$ndssumma." ".$currency->symbol,$kvtpl); $kvtplpdf = preg_replace("/{summapropis}/u",num2str($money_kv,$kv->currency,$kvLang).", ".$_lang[FakturaVTomChisleNds]." ".$ndssumma." ".$currency->symbol,$kvtplpdf);
} else {
$money_kv_beznds = $money_kv;
$kvtpl = str_replace("{ndsval}","0",$kvtpl); $kvtplpdf = str_replace("{ndsval}","0",$kvtplpdf);
$kvtpl = str_replace("{nds}",$_lang[FakturaBezNds],$kvtpl); $kvtplpdf = str_replace("{nds}",$_lang[FakturaBezNds],$kvtplpdf);
$kvtpl = preg_replace("/{ndssumma}/u","0",$kvtpl); $kvtplpdf = preg_replace("/{ndssumma}/u","0",$kvtplpdf);
$kvtpl = preg_replace("/{summapropis}/u",num2str($money_kv,$kv->currency,$kvLang),$kvtpl); $kvtplpdf = preg_replace("/{summapropis}/u",num2str($money_kv,$kv->currency,$kvLang),$kvtplpdf);
}
$kvtpl = preg_replace("/{summa}/u",$money_kv,$kvtpl); $kvtplpdf = preg_replace("/{summa}/u",$money_kv,$kvtplpdf);
$kvtpl = str_replace("{summabeznds}",$money_kv_beznds,$kvtpl); $kvtplpdf = str_replace("{summabeznds}",$money_kv_beznds,$kvtplpdf);
$kvtpl = preg_replace("/(<!--RowBegin-->.+<!--RowEnd-->)/isu","",$kvtpl); $kvtplpdf = preg_replace("/(<!--RowBegin-->.+<!--RowEnd-->)/isu","",$kvtplpdf);
@mysql_query("update kvitancii_db set html='".htmlEncode($kvtpl)."',pdf='".htmlEncode($kvtplpdf)."' where id='$kvdbid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
if ($type) {
$dompdf = new DOMPDF();
$dompdf->set_paper(array(0,0,595,840), 'portrait');
$dompdf->load_html($kvtplpdf);
$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 $kvtpl;
}
}
}
function checkDNS($domain, $zone_id, $ns1, $ns2, $ns3='', $ns4='') {
global $GLOBALerror, $_lang;
$zone = GetZoneById($zone_id);
if ($zone->id) {
$command = $zone->checkNSScript;
$reply = $zone->checkNSScriptReply;
if ($command) {
$command = preg_replace("/{domain}/ui","$domain",$command);
$command = preg_replace("/{ns1}/ui","$ns1",$command);
$command = preg_replace("/{ns2}/ui","$ns2",$command);
$command = preg_replace("/{ns3}/ui","$ns3",$command);
$command = preg_replace("/{ns4}/ui","$ns4",$command);
exec("$command", $result, $resultstatus);
mconnect();
if ($resultstatus) { $error = $_lang[checkDNSCantRunScriptError]; }
else {
$result = @join("",$result);
if (!$reply or preg_match("/".$reply."/ui",$result)) { $error = ""; }
else { $error = $_lang[checkDNSNoZoneAtServerError]; }
}
}
else { $error = $_lang[checkDNSNoScriptInZoneError]; }
} else { $error = $_lang[checkDNSNoZoneError]." ".$domain; }
if ($error) {
$GLOBALerror = $error;
return false;
} else {
return true;
}
}
function GotoUserAccount($orderid) {
$order = GetOrderById($orderid);
if (($order->status or ($order->testPeriod and $order->serverlogin and $order->serverpassword)) and $order->serverlogin and $order->serverpassword) {
$user = GetUserById($order->uid);
$server = GetServers($order->serverid);
if (($server->protocol and $server->ip) or ($server->type = "gamecp" and $server->ventrilo_url)) {
if ($server->type == "da") {
print "
<HTML>
<BODY onload="document.login.submit()">
<FORM name=login ACTION="".$server->protocol."://".$server->ip.":2222/CMD_LOGIN" METHOD=POST>
<input type=hidden name=referer value='/'>
<input type=hidden name=username value='$order->serverlogin'>
<input type=hidden name=password value='".decodePwd($order->serverpassword)."'>
<input type=submit name=Submit value='Login'>
</FORM>
</BODY>
</HTML>
";
}
if ($server->type == "cpanel") {
if ($server->protocol == "http") {$port = "2082";}
else if ($server->protocol == "https") {$port = "2083";}
Header("Location: ".$server->protocol."://".$server->ip.":".$port."/login/?user=".$order->serverlogin."&pass=".decodePwd($order->serverpassword));exit;
}
if ($server->type == "isp") {
if (!$server->folder) { $server->folder = "manager"; }
Header("Location: ".$server->protocol."://".$server->ip."/".$server->folder."/ispmgr?username=".$order->serverlogin."&password=".decodePwd($order->serverpassword)."&func=auth&checkcookie=no");exit;
}
if ($server->type == "vdsmanager") {
if (!$server->folder) { $server->folder = "manager"; }
Header("Location: ".$server->protocol."://".$server->ip."/".$server->folder."/vdsmgr?username=".$order->serverlogin."&password=".decodePwd($order->serverpassword)."&func=auth&checkcookie=no");exit;
}
if ($server->type == "plesk") {
Header("Location: ".$server->protocol."://".$server->ip.":8443/login_up.php3?login_name=".$order->serverlogin."&passwd=".decodePwd($order->serverpassword)."&login_locale=default");exit;
}
if ($server->type == "plesk10") {
Header("Location: ".$server->protocol."://".$server->ip.":8443/login_up.php3?login_name=".$order->serverlogin."&passwd=".decodePwd($order->serverpassword)."&login_locale=default");exit;
}
if ($server->type == "gamecp") {
Header("Location: ".$server->ventrilo_url."?user=".$order->serverlogin."&pass=".decodePwd($order->serverpassword)."&sublogin=Login");exit;
}
if ($server->type == "hypervm" or $server->type == "hypervmxen") {
if ($server->protocol and $server->ip) {
if ($server->protocol == "http") {$port = "8888";}
else if ($server->protocol == "https") {$port = "8887";}
Header("Location: ".$server->protocol."://".$server->ip.":".$port."/htmllib/phplib/?frm_clientname=".$order->serverlogin."&frm_password=".decodePwd($order->serverpassword));exit;
}
}
}
}
}
function sendSMS($userId, $adminId, $smsmsg, $sendErrorEmail = 1) {
global $GLOBALerror, $dbhost, $dbuser, $dbpass, $dbname;
$smsGateway = GetSetting("smsGateway");
$smsGateway = GetSMSGatewayById($smsGateway);
if ($smsGateway->id and $smsGateway->active) {
if ($userId) { $user = GetUserById($userId); }
else if ($adminId) { $user = GetAdminById($adminId); }
if ($user->id) {
if ($user->mobile) {
if ($smsGateway->url and $smsGateway->text1 and $smsGateway->text2) {
if (GetSetting("smsGatewayTranslit")) { $smsmsg = GotoTranslit($smsmsg); }
if ($smsmsg) {
$smsGatewaySender = GetSetting("smsGatewaySender");
$smsGatewayLogsEnable = GetSetting("smsGatewayLogsEnable");
if ($smsGatewayLogsEnable) {
@mysql_query("insert into smsgateways_logs (gateway,userid,adminid,mobile,msg,dt) VALUES('$smsGateway->id','$userId','$adminId','$user->mobile','$smsmsg',NOW())") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$smsid=mysql_insert_id();
}
if ($smsGateway->type == "epochtasms") {
$sms = new EPOCHTASMS();
$sms->init($smsGateway->url, $smsGateway->text1, decodePwd($smsGateway->text2));
$credits = $sms->sendSMS($user->mobile, $smsGatewaySender, $smsid, $smsmsg);
mconnect();
if ($credits) {
$error = "";
if ($smsid) {
@mysql_query("update smsgateways_logs set cost='$credits' where id='$smsid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
} else {
$error = $sms->error;
if ($smsid) {
@mysql_query("delete from smsgateways_logs where id='$smsid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
}
else if ($smsGateway->type == "smsplan") {
$sms = new SMSPLAN();
$sms->init($smsGateway->url, $smsGateway->text1, decodePwd($smsGateway->text2));
$gwMsgId = $sms->sendSMS($user->mobile, $smsGatewaySender, $smsmsg);
mconnect();
if ($gwMsgId) {
$error = "";
if ($smsid) {
@mysql_query("update smsgateways_logs set gwMsgId='$gwMsgId' where id='$smsid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
} else {
$error = $sms->error;
if ($smsid) {
@mysql_query("delete from smsgateways_logs where id='$smsid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
}
else if ($smsGateway->type == "bytehand") {
$sms = new BYTEHAND();
$sms->init($smsGateway->url, $smsGateway->text1, decodePwd($smsGateway->text2));
$gwMsgId = $sms->sendSMS($user->mobile, $smsGatewaySender, $smsmsg);
mconnect();
if ($gwMsgId) {
$error = "";
if ($smsid) {
@mysql_query("update smsgateways_logs set gwMsgId='$gwMsgId' where id='$smsid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
} else {
$error = $sms->error;
if ($smsid) {
@mysql_query("delete from smsgateways_logs where id='$smsid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
}
else if ($smsGateway->type == "qtelecom") {
$sms = new QTELECOM();
$sms->init($smsGateway->url, $smsGateway->text1, decodePwd($smsGateway->text2));
$gwMsgId = $sms->sendSMS($user->mobile, $smsGatewaySender, $smsmsg);
mconnect();
if ($gwMsgId) {
$error = "";
if ($smsid) {
@mysql_query("update smsgateways_logs set gwMsgId='$gwMsgId' where id='$smsid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
} else {
$error = $sms->error;
if ($smsid) {
@mysql_query("delete from smsgateways_logs where id='$smsid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
}
else { $error = "Неизвестный тип SMS-шлюза ($smsGateway->type)"; }
}
else { $error = "Отсутствует SMS-сообщение для отправки."; }
}
else { $error = "Не указан URL, логин или пароль для SMS-шлюза $smsGateway->type."; }
}
else { $error = "У получателя не указан мобильный телефон.";}
}
else { $error = "Не удалось найти получателя."; }
}
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически отправить SMS ($smsmsg) по следующей причине:nn$error";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка отправки SMS";
$admEmails=GetAdminEmailsWhereTrueParam("sendsmserror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$errormsg);
}
}
return false;
} else {
return true;
}
}
function getSMSStatus($id) {
global $GLOBALerror, $dbhost, $dbuser, $dbpass, $dbname;
$sms=@mysql_query("select * from smsgateways_logs where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$sms=@mysql_fetch_object($sms);
if ($sms->id) {
$id = $sms->id;
$gwMsgId = $sms->gwMsgId;
$smsGateway = GetSMSGatewayById($sms->gateway);
if ($smsGateway->id) {
if ($smsGateway->url and $smsGateway->text1 and $smsGateway->text2) {
if ($smsGateway->type == "epochtasms") {
$sms = new EPOCHTASMS();
$sms->init($smsGateway->url, $smsGateway->text1, decodePwd($smsGateway->text2));
$result = $sms->getSMSStatus($id);
mconnect();
if ($result) {
return $result;
} else {
$error = $sms->error;
}
}
else if ($smsGateway->type == "smsplan") {
$sms = new SMSPLAN();
$sms->init($smsGateway->url, $smsGateway->text1, decodePwd($smsGateway->text2));
$result = $sms->getSMSStatus($gwMsgId);
mconnect();
if ($result) {
return $result;
} else {
$error = $sms->error;
}
}
else if ($smsGateway->type == "bytehand") {
$sms = new BYTEHAND();
$sms->init($smsGateway->url, $smsGateway->text1, decodePwd($smsGateway->text2));
$result = $sms->getSMSStatus($gwMsgId);
mconnect();
if ($result) {
return $result;
} else {
$error = $sms->error;
}
}
else if ($smsGateway->type == "qtelecom") {
$sms = new QTELECOM();
$sms->init($smsGateway->url, $smsGateway->text1, decodePwd($smsGateway->text2));
$result = $sms->getSMSStatus($gwMsgId);
mconnect();
if ($result) {
return $result;
} else {
$error = $sms->error;
}
}
else { $error = "Неизвестный тип SMS-шлюза ($smsGateway->type)"; }
}
else { $error = "Не указан URL, логин или пароль для SMS-шлюза $smsGateway->type."; }
}
else { $error = "Не найден SMS-шлюз ID # $sms->gateway."; }
}
else { $error = "Не найдено SMS-сообщение ID # $id."; }
$GLOBALerror = $error;
if ($error) {
return false;
}
}
function html2txt($str) {
$search = array (
"'<head>.*?</head>'si",
"'<script[^>]*?>.*?</script>'si",
"'<title[^>]*?>.*?</title>'si",
"'<[/!]*?[^<>]*?>'si",
"'([rn])[s]+'",
"'&(quot|#34);'i",
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(d+);'e"
);
$replace = array (
"",
"",
"",
"",
"\1",
""",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\1)"
);
$str = preg_replace ($search, $replace, $str);
return $str;
}
function printCurrencyCodes($inputFieldName, $selectedValue) {
print "<select class=input name=$inputFieldName>";
$r = GetCurrencys();
while ($rr = @mysql_fetch_object($r)) {
if ($rr->code == $selectedValue) { $selected = "selected"; } else { $selected = ""; }
print "<option value='$rr->code' $selected>$rr->code</option>";
}
print "</select>";
}
function checkMobile() {
$registerNeedMobile = GetSetting("registerNeedMobile");
$registerNeedMobileVerification = GetSetting("registerNeedMobileVerification");
if ($registerNeedMobile == 2 and $registerNeedMobileVerification) {
$user = GetUserById($_SESSION["userId"]);
if ($user->mobileVerification == 1) { return true; }
else { return false; }
} else {
return true;
}
}
function checkSettings($id) {
global $GLOBALerror, $GLOBALerrorFields, $_lang;
$user = GetUserById($id);
$registerNeedFIO = GetSetting("registerNeedFIO");
$GLOBALerror = "";
$f = array();
if ($registerNeedFIO == 2) {
if (mb_strlen($user->surname) < 3) { $f[] = $_lang[ProfileSurname]; $ff[] = "surname"; }
if (mb_strlen($user->name) < 2) { $f[] = $_lang[ProfileName]; $ff[] = "name"; }
if (mb_strlen($user->otchestvo) < 3) { $f[] = $_lang[ProfileOtchestvo]; $ff[] = "otchestvo"; }
}
if (count($f) > 0) { $GLOBALerror = $_lang[SettingsErrorFields].": ".@join(", ",$f);}
if (count($ff) > 0) { $GLOBALerrorFields = @join(", ",$ff);}
if ($GLOBALerror or $GLOBALerrorFields) { return false; }
else {return true;}
}
function getZoneTxtByDomainTxt($domain) {
$zone = @mb_split(".", $domain);
unset($zone[0]);
$zone = @join(".", $zone);
return $zone;
}
?>