Файл: cron5min.php
Строк: 1258
<?
$full_home_path = dirname(__FILE__);
require_once($full_home_path.'/_rootload.php');
mconnect();
EnableLanguages(1);
if (!GetCurrentCurrency()) { print $_lang[ErrorGetCurrentCurrency]; mclose(); exit; }
@set_time_limit(0);
$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');
$support_email=GetSetting("support_email");
# Обработка EPP POLL-сообщений (hostmasterepp, nicdpua, subreg)
$registrators = @mysql_query("select * from registrators where (type='hostmasterepp' OR type='nicdpua' OR type='ppua' OR type='subreg') and active='1'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($registrators) > 0) {
while ($registrator = @mysql_fetch_object($registrators)) {
$error = "";
$registratorParams_url = $registrator->url;
$registratorParams_port = $registrator->port;
$registratorParams_user = $registrator->text1;
$registratorParams_password = decodePwd($registrator->text2);
$registratorParams_ssl = $registrator->text3;
$registratorParams_log = $registrator->check1;
if ($registratorParams_url and ($registratorParams_port or $registrator->type == "subreg") and $registratorParams_user and $registratorParams_password) {
if ($registrator->type == "hostmasterepp") {
$registratorEPP = new HOSTMASTEREPP;
$registratorEPP->init($registratorParams_url,$registratorParams_port,$registratorParams_user,$registratorParams_password,$registratorParams_ssl,$registratorParams_log);
}
else if ($registrator->type == "nicdpua") {
$registratorEPP = new NICDPUA;
$registratorEPP->init($registratorParams_url,$registratorParams_port,$registratorParams_user,$registratorParams_password,$registratorParams_ssl,$registratorParams_log);
}
else if ($registrator->type == "ppua") {
$registratorEPP = new PPUA;
$registratorEPP->init($registratorParams_url,$registratorParams_port,$registratorParams_user,$registratorParams_password,$registratorParams_log);
}
else if ($registrator->type == "subreg") {
$registratorEPP = new SUBREG;
$registratorEPP->init($registratorParams_url,$registratorParams_user,$registratorParams_password,$registratorParams_log);
}
$pollMessagesLeft = 1;
while ($pollMessagesLeft) {
$result = $registratorEPP->reqPoll();
if ($registratorEPP->error) { $error = $registratorEPP->error; break;}
if ($result['msgId']) {
if (preg_match("/^xn--/ui",$result['domain'])) {
$idna = new idna_convert();
$result['domain'] = $idna->decode($result['domain']);
}
if ($result['type'] == "transferRequest" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
mconnect();
$domain = GetDomainByDomain($result['domain']);
if ($domain->id and !$domain->transferReq and $domain->status != "3") {
@mysql_query("update orders_domains set transferReq='1' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$subject = "Запрос на трансфер домена";
$template = "Получен запрос на трансфер доменного имени $domain->domain к регистратору [".$result['registrator']."].nnВы можете подтвердить/отменить трансфер в редактировании заказа на домен.nn--nRootPanel";
$admEmails=GetAdminEmailsWhereTrueParam("sendtransferreq");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$template);
}
}
}
else if ($result['type'] == "transferRequestReject" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
}
else if ($result['type'] == "transferCancelled" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
}
else if ($result['type'] == "contactCreated" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
}
else if ($result['type'] == "contactModified" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
}
else if ($result['type'] == "domainCreated" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
}
else if ($result['type'] == "domainModified" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
}
else if ($result['type'] == "domainAutoRenewed" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
}
else if ($result['type'] == "transferApproved" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
mconnect();
$domain = GetDomainByDomain($result['domain']);
if ($domain->id and $domain->status == "3") {
$user = GetUserById($domain->uid);
$zone = GetZoneByDomainOrderId($domain->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);
}
$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 = $registratorEPP->createContact($name, $org, $address, $city, $oblast, $profile->post, $profile->country, $telNo, $faxNo, $profile->email, $disclose);
if (!$contactId) { $error = $registratorEPP->error."rnrnPOLL XML:rnrn".$result['xml']; break; }
$authinfo = generatePassword(8);
if ($registrator->type == "hostmasterepp") {
if (!$registratorEPP->updateContactDomain($domain->domain, $domain->hostmasterEppContactId, $contactId, $authinfo)) { $error = $registratorEPP->error."rnrnPOLL XML:rnrn".$result['xml']; break; }
} else if ($registrator->type == "nicdpua") {
if (!$registratorEPP->updateContactDomain($domain->domain, $domain->nicdpuaContactId, $contactId, $authinfo)) { $error = $registratorEPP->error."rnrnPOLL XML:rnrn".$result['xml']; break; }
}
mconnect();
if ($registrator->type == "hostmasterepp") {
@mysql_query("update orders_domains set status='1',todate='".$result['exDate']."',hostmasterEppContactId='$contactId',transferAuth='$authinfo' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else if ($registrator->type == "nicdpua") {
@mysql_query("update orders_domains set status='1',todate='".$result['exDate']."',nicdpuaContactId='$contactId',transferAuth='$authinfo' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
$tpl=GetTpl('email_touser_domain_transfer', $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($subject and $template) {
$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 if ($result['type'] == "domainPendingDelete" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
}
else if ($result['type'] == "domainDeleted" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
if ($domain->id and $domain->status) {
$user = GetUserById($domain->uid);
@mysql_query("update orders set domain_reg='0' where domain='$domain->domain'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("update bills set domain_id='0', domain_srok='0', money_domain='0' where domain_id='$domain->id' and NOT(host_id='0')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if ($domain->dnsServerId) {
deleteDomainZoneAtServer($domain->id);
}
@mysql_query("delete from orders_domains where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$bs = @mysql_query("select * from bills where domain_id='$domain->id' and host_id='0'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($b = @mysql_fetch_object($bs)) {
if (!$b->status) {
@mysql_query("delete from bills where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
} else {
@mysql_query("update bills set archived=1 where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
$tpl=GetTpl('email_touser_domain_delete', $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($subject and $template) {
$varLng = LoadLanguageToVariable($user->lang);
$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);
$template = str_replace('{reason}',$varLng[DomainDeleteReasonRegistratorCancel],$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 if ($result['type'] == "domainExpired" and ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua")) {
mconnect();
$domain = GetDomainByDomain($result['domain']);
if ($domain->id and $domain->status == "1") {
$user = GetUserById($domain->uid);
mconnect();
if (suspendDomain($domain->id, 1, 1)) {
@mysql_query("update orders_domains set status='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
}
else if ($result['type'] == "domainActivated" and $registrator->type == "ppua") {
mconnect();
$domain = GetDomainByDomain($result['domain']);
if ($domain->id and $domain->status == "3") {
$user = GetUserById($domain->uid);
mconnect();
@mysql_query("update orders_domains set status='1' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$tpl=GetTpl('email_touser_domain_create', $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($subject and $template) {
$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 if ($domain->id) {
@mysql_query("update orders_domains set ppuaSentRenew='0' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
else if ($result['type'] == "domainCanceled" and $registrator->type == "ppua") {
mconnect();
$domain = GetDomainByDomain($result['domain']);
if ($domain->id and $domain->status and $domain->ppuaSentRenew) {
$bill = @mysql_query("select domain_srok from bills where status='1' and renew='1' and domain_id='$domain->id' order by id desc LIMIT 0,1") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$bill = @mysql_fetch_object($bill);
if ($bill->domain_srok) {
@mysql_query("update orders_domains set ppuaSentRenew='0',todate=DATE_SUB(todate, INTERVAL ".$bill->domain_srok." MONTH) where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
} else {
@mysql_query("update orders_domains set ppuaSentRenew='0' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$subject = "Ошибка отмены продления домена";
$template = "Клиент заказал продление доменного имени $domain->domain, но не подтвердил его у регистратора. Биллинг не смог автоматически изменить срок до когда зарегистрирован домен, т.к. не найден соответствующий счет.nn--nRootPanel";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$template);
}
}
}
else if ($domain->id and $domain->status) {
$user = GetUserById($domain->uid);
@mysql_query("update orders set domain_reg='0' where domain='$domain->domain'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("update bills set domain_id='0', domain_srok='0', money_domain='0' where domain_id='$domain->id' and NOT(host_id='0')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if ($domain->dnsServerId) {
deleteDomainZoneAtServer($domain->id);
}
@mysql_query("delete from orders_domains where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$bs = @mysql_query("select * from bills where domain_id='$domain->id' and host_id='0'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($b = @mysql_fetch_object($bs)) {
if (!$b->status) {
@mysql_query("delete from bills where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
} else {
@mysql_query("update bills set archived=1 where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
$tpl=GetTpl('email_touser_domain_delete', $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($subject and $template) {
$varLng = LoadLanguageToVariable($user->lang);
$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);
$template = str_replace('{reason}',$varLng[DomainDeleteReasonRegistratorCancel],$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 if ($result['type'] == "domainHeld" and $registrator->type == "ppua") {
mconnect();
$domain = GetDomainByDomain($result['domain']);
if ($domain->id and $domain->status == "1") {
$user = GetUserById($domain->uid);
mconnect();
@mysql_query("update orders_domains set status='2' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
}
else if ($result['type'] == "transferPending" and $registrator->type == "ppua") {
mconnect();
$domain = GetDomainByDomain($result['domain']);
if ($domain->id and !$domain->transferReq) {
@mysql_query("update orders_domains set transferReq='1' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$subject = "Запрос на трансфер домена";
$template = "Получен запрос на трансфер доменного имени $domain->domain к регистратору [".$result['registrator']."].nnВы можете подтвердить/отменить трансфер в редактировании заказа на домен.nn--nRootPanel";
$admEmails=GetAdminEmailsWhereTrueParam("sendtransferreq");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$template);
}
}
}
else if ($result['type'] == "transferRequestApprove" and $registrator->type == "ppua") {
mconnect();
$domain = GetDomainByDomain($result['domain']);
if ($domain->id and $domain->transferReq) {
$user = GetUserById($domain->uid); if (!$user->id) { $error = "Пользователь ID # $domain->uid не найден.rnrnPOLL XML:rnrn".$result['xml']; break; }
mconnect();
@mysql_query("update orders set domain_reg='0' where domain='$domain->domain'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("update bills set domain_id='0', domain_srok='0', money_domain='0' where domain_id='$domain->id' and NOT(host_id='0')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if ($domain->dnsServerId) {
deleteDomainZoneAtServer($domain->id);
}
@mysql_query("delete from orders_domains where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$bs = @mysql_query("select * from bills where domain_id='$domain->id' and host_id='0'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($b = @mysql_fetch_object($bs)) {
if (!$b->status) {
@mysql_query("delete from bills where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
} else {
@mysql_query("update bills set archived=1 where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
$tpl=GetTpl('email_touser_domain_delete', $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($subject and $template) {
$varLng = LoadLanguageToVariable($user->lang);
$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);
$template = str_replace('{reason}',$varLng[DomainDeleteReasonTransferRequestApprove],$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 if ($result['type'] == "transferReject" and $registrator->type == "ppua") {
mconnect();
$domain = GetDomainByDomain($result['domain']);
if ($domain->id and !$domain->transferReq) {
$user = GetUserById($domain->uid); if (!$user->id) { $error = "Пользователь ID # $domain->uid не найден.rnrnPOLL XML:rnrn".$result['xml']; break; }
mconnect();
@mysql_query("update orders set domain_reg='0' where domain='$domain->domain'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("update bills set domain_id='0', domain_srok='0', money_domain='0' where domain_id='$domain->id' and NOT(host_id='0')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if ($domain->dnsServerId) {
deleteDomainZoneAtServer($domain->id);
}
@mysql_query("delete from orders_domains where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$bs = @mysql_query("select * from bills where domain_id='$domain->id' and host_id='0'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($b = @mysql_fetch_object($bs)) {
if (!$b->status) {
@mysql_query("delete from bills where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
} else {
@mysql_query("update bills set archived=1 where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
$tpl=GetTpl('email_touser_domain_delete', $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($subject and $template) {
$varLng = LoadLanguageToVariable($user->lang);
$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);
$template = str_replace('{reason}',$varLng[DomainDeleteReasonTransferReject],$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 if ($result['type'] == "domainPendingDelete" and $registrator->type == "ppua") {
}
else if ($result['type'] == "domainDeleted" and $registrator->type == "ppua") {
}
else if ($registrator->type == "subreg") {
$orderInfo = $registratorEPP->infoOrder($result['orderid']);
if ($orderInfo['type'] == "Create_Domain" and $orderInfo['status'] == "Completed") {
$domain = GetDomainByDomain($orderInfo['domain']);
if ($domain->id and $domain->status == "3") {
$user = GetUserById($domain->uid);
$expiration = $registratorEPP->getExpiration($domain->domain);
if ($domain->ns1ip or $domain->ns2ip or $domain->ns3ip or $domain->ns4ip) { $registratorEPP->updateNS($domain->domain, $domain->ns1, $domain->ns2, $domain->ns3, $domain->ns4, $domain->ns1ip, $domain->ns2ip, $domain->ns3ip, $domain->ns4ip); }
if ($domain->privacy) { $registratorEPP->updateDomainPrivacy($domain->domain, 1); }
mconnect();
@mysql_query("update orders_domains set status='1',todate='".$expiration."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$tpl=GetTpl('email_touser_domain_create', $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($subject and $template) {
$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 if ($orderInfo['type'] == "Transfer_Domain" and $orderInfo['status'] == "Completed") {
$domain = GetDomainByDomain($orderInfo['domain']);
if ($domain->id and $domain->status == "3") {
$user = GetUserById($domain->uid);
$expiration = $registratorEPP->getExpiration($domain->domain);
if ($domain->ns1ip or $domain->ns2ip or $domain->ns3ip or $domain->ns4ip) { $registratorEPP->updateNS($domain->domain, $domain->ns1, $domain->ns2, $domain->ns3, $domain->ns4, $domain->ns1ip, $domain->ns2ip, $domain->ns3ip, $domain->ns4ip); }
if ($domain->privacy) { $registratorEPP->updateDomainPrivacy($domain->domain, 1); }
mconnect();
@mysql_query("update orders_domains set status='1',todate='".$expiration."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$tpl=GetTpl('email_touser_domain_transfer', $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($subject and $template) {
$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 if ($orderInfo['status'] == "Failed" or $orderInfo['status'] == "Wait_For_Payment" or $orderInfo['status'] == "Wait_For_Documents") {
$subject = "Ошибка выполнения заявки [subreg.cz]";
$template = "Ошибка выполнения заявки для домена ".$orderInfo['domain'].":nnТип заявки: ".$orderInfo['type']."nСтатус заявки: ".$orderInfo['status']."nКод ошибки: ".$orderInfo['errorcode']."nОшибка: ".$orderInfo['message']."nn--nRootPanel";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$template);
}
}
}
else {
$error = "Неизвестный тип POLL-сообщения.rnrnPOLL XML:rnrn".$result['xml']; break;
}
$registratorEPP->ackPoll($result['msgId']);
} else {
$result['msgCount'] = 0;
}
if ($result['msgCount'] <= 1) { $pollMessagesLeft = 0; }
}
if ($registrator->type == "hostmasterepp" or $registrator->type == "nicdpua") {
$registratorEPP->logout();
} else if ($registrator->type == "ppua") {
$registratorEPP->disconnect();
}
mconnect();
} else {
$error = "Отсутствуют необходимые данные для подключения в настройках регистратора.n";
}
if ($error) {
$template = "Не удалось обработать EPP POLL-сообщения по следующей причине:rnrn$errorrnrn--rnRootPanel";
$subject="Ошибка обработки EPP POLL-сообщений ($registrator->name)";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$template);
}
}
}
}
# Проверка статуса заявок на регистрацию доменов через started.ru
$domains = @mysql_query("select d.* from orders_domains as d, registrators as r where NOT(d.startedRequestId=0) and d.autoregby=r.id and r.type='started'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($domains) > 0) {
while ($domain = mysql_fetch_object($domains)) {
$user = GetUserById($domain->uid);
$registrator = GetRegistratorById($domain->autoregby);
$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->checkDomainState($domain->startedRequestId);
if ($result[domainId] and $result[state] == "done") {
@mysql_query("update orders_domains set startedDomainId='$result[domainId]',startedRequestId='0',ns1='',ns2='',ns3='',ns4='',status=1 where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$tpl=GetTpl('email_touser_domain_create', $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($subject and $template) {
$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 if ($result[state] == "canceled") {
@mysql_query("update orders_domains set startedRequestId='0',autoregby='',panel_url='',panel_user='',panel_pwd='' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
} else if (!$result[state]) {
$result[state] = "Ошибка при попытке получить статус заявки (".$started->error.")";
}
if ($result[state] != "done" and $result[state] != "new" and $result[state] != "processing" and $result[state] != "waiting" and $result[state] != "ready") {
if ($domain->startedSentStatus != $result[state]) {
@mysql_query("update orders_domains set startedSentStatus='$result[state]' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$template = "Неудовлетворительный статус заявки по регистрации домена $domain->domain для пользователя $user->login через $registrator->namennСтатус заявки: ".$result[state]."rnrn--rnRootPanel";
$subject="Ошибка при проверке статуса регистрации домена";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$template);
}
}
}
}
}
}
$ticketsEnable=GetSetting("ticketsEnable");
$ticketsFetchEnable=GetSetting("ticketsFetchEnable");
$ticketsFetchServer=GetSetting("ticketsFetchServer");
$ticketsFetchPort=GetSetting("ticketsFetchPort");
$ticketsFetchProtocol=GetSetting("ticketsFetchProtocol");
$ticketsFetchSecure=GetSetting("ticketsFetchSecure");
$ticketsFetchUser=GetSetting("ticketsFetchUser");
$ticketsFetchPassword=decodePwd(GetSetting("ticketsFetchPassword"));
$ticketsFetchNoDelete=GetSetting("ticketsFetchNoDelete");
$ticketsFetchSaveFiles=GetSetting("ticketsFetchSaveFiles");
$ticketsFetchSendNoReg=GetSetting("ticketsFetchSendNoReg");
$ticketsFetchDepartment=GetSetting("ticketsFetchDepartment");
$ticketsFetchIgnoreEmails=GetSetting("ticketsFetchIgnoreEmails"); $ticketsFetchIgnoreEmails=@mb_split("rn",$ticketsFetchIgnoreEmails);
# Сборщик почты
if ($ticketsEnable and $ticketsFetchEnable) {
$error = "";
if ($ticketsFetchServer and $ticketsFetchPort and $ticketsFetchProtocol and $ticketsFetchUser and $ticketsFetchPassword) {
$rpimap = new RPIMAP();
$rpimap->init($ticketsFetchProtocol, $ticketsFetchServer, $ticketsFetchPort, $ticketsFetchSecure, $ticketsFetchUser, $ticketsFetchPassword);
if ($ticketsFetchNoDelete) {$delete = 0;} else {$delete = 1;}
$res = $rpimap->getMessages($delete,$ticketsFetchSaveFiles,$ticketsFetchIgnoreEmails);
mconnect();
if (!$rpimap->error) {
if (@count($res) > 0) {
while(list($i,$v) = @each($res)) {
// $v[from]
// $v[priority] - 2: high, 3: normal, 4: low
// $v[subject]
// $v[message]
$v[from] = trim($v[from]);
$v[priority] = trim($v[priority]);
$v[subject] = trim($v[subject]);
$v[message] = trim($v[message]);
$user = GetUserByEmail($v[from]);
if ($user->id) {
if ($v[message]) {
if (!$v[subject]) { $v[subject] = "no subject"; }
if ($v[priority] == "2") { $priority = "2"; } else if ($v[priority] == "4") { $priority = "0"; } else { $priority = "1"; }
$z=@mysql_query("select * from tickets where parentid='0' and priority='$priority' and subject='".htmlEncode($v[subject])."' and userid='$user->id' and message='".addslashes(htmlEncode($v[message]))."'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($z) == 0) {
@mysql_query("insert into tickets (priority,dt,subject,userid,message,department) values('$priority',NOW(),'".htmlEncode($v[subject])."','$user->id','".addslashes(htmlEncode($v[message]))."','$ticketsFetchDepartment')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$ticketid=mysql_insert_id();
$pwd = generatePassword(25);
@mysql_query("update users set tempPassword='".crypt($pwd)."' where id='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$attached=array();
if ($ticketsFetchSaveFiles) {
if (@count($v[files]) > 0) {
while (list($qq,$oneFile) = @each($v[files])) {
// $oneFile[name] - имя файла
// $oneFile[file] - содержимое файла
$newFile = "ticket_".$ticketid."_".$qq;
if ($oneFile[name] and $oneFile[file]) {
if ($handle = fopen($full_home_path."/_rootfiles/".$newFile, 'a')) {
fwrite($handle, $oneFile[file]);
fclose($handle);
$attached[] = "$newFile::$oneFile[name]";
}
}
}
}
if (@count($attached) > 0) {
$attached = @join(":x:",$attached);
@mysql_query("update tickets set attachedFiles='$attached' where id='$ticketid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
$tpl=GetTpl('email_touser_ticket_new',$user->lang);
$subj=$tpl[subject]; $template=$tpl[template];
if ($subj and $template) {
$subj = str_replace('{id}',$ticketid,$subj);
$subj = str_replace('{priority}',$_priority[$priority],$subj);
$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('{subject}',$v[subject],$template);
$template = str_replace('{message}',$v[message],$template);
$template = str_replace('{id}',$ticketid,$template);
$template = str_replace('{link}',$full_www_path."billing.php?do=tickets&sub=view&id=$ticketid&login=$user->login&pass=$pwd",$template);
WriteMailLog($subj,$template,$user->id);
sendmail($user->email,$company_name,$support_email,$subj,$template,'','',$tpl[type]);
sendmail($user->email2,$company_name,$support_email,$subj,$template,'','',$tpl[type]);
}
// Уведомление админам
$subject_msg = "[#$ticketid] New ticket [важность ".$_priority[$priority]."]";
$message = "Пользователь ".$user->login." открыл новый тикет "$v[subject]" (ID # $ticketid)nnПерейти к тикету можно по ссылке: ".$full_www_path.$admin_script."?do=tickets&sub=view&id=$ticketidnnСообщение:nn$v[message]";
$admEmails=GetAdminEmailsWhereTrueParam("sendticket",$ticketsFetchDepartment);
if (count($admEmails) > 0) {
WriteMailLog($subject_msg,$message);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$support_email,$subject_msg,$message);
}
// СМС уведомление админам
if (GetSetting("smsGateway")) {
$smsmsg = "[".$_prioritysms[$priority]."] New ticket #$ticketid: $v[subject]";
$admIds=GetAdminIdsWhereTrueParam("sms_sendticketnew",$ticketsFetchDepartment);
while (list($i,$aid) = @each($admIds)) {
$smsAdmin=GetAdminById($aid);
if ($smsAdmin->mobile) {
sendSMS('',$aid,$smsmsg);
}
}
}
}
}
}
else {
if ($ticketsFetchSendNoReg) {
// отправляем уведомление для незарегистрированного email
$tpl=GetTpl('email_touser_ticket_noreg');
$subj=$tpl[subject]; $template=$tpl[template];
if ($subj and $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('{feedback_url}',$full_www_path."feedback.php",$template);
sendmail($v[from],$company_name,$support_email,$subj,$template,'','',$tpl[type]);
}
}
}
}
}
}
else { $error = $rpimap->error; }
}
else { $error = "Отсутствуют необходимые для работы Сборщика почты настройки."; }
if ($error) {
$template = "Не удалось запустить Сборщик почты по следующей причине:rnrn$errorrnrn--rnRootPanel";
$subject="Ошибка при запуске Сборщика почты";
$admEmails=GetAdminEmailsWhereTrueParam("sendfetcherror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$template);
}
}
}
mclose();
?>