function LogicBoxes_Contract_Register($Settings, $PepsonID, $Person, $DomainZone) { /****************************************************************************/ $__args_types = array('array', 'string', 'array', 'string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Wsdl = System_Element('config/Wsdl/Customer.wsdl'); if (Is_Error($Wsdl)) { return ERROR | @Trigger_Error(500); } #----------------------------------------------------------------------------- $AddCustomer = new SoapClient($Wsdl, array('exceptions' => 0)); #----------------------------------------------------------------------------- $Params = array('SERVICE_USERNAME' => $Settings['Login'], 'SERVICE_PASSWORD' => $Settings['Password'], 'SERVICE_ROLE' => 'reseller', 'SERVICE_LANGPREF' => 'ru', 'SERVICE_PARENTID' => $Settings['ParentID'], 'customerUserName' => $Person['Email'], 'customerPassword' => UniqID()); #----------------------------------------------------------------------------- switch ($PepsonID) { case 'Natural': #------------------------------------------------------------------------- $Params['name'] = SPrintF('%s %s %s', Translit($Person['Name']), Mb_SubStr(Translit($Person['Lastname']), 0, 1), Translit($Person['Sourname'])); $Params['company'] = 'N/A'; $Params['address1'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress'])); $Params['address2'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress'])); $Params['address3'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress'])); $Params['city'] = Translit($Person['pCity']); $Params['state'] = Translit($Person['pState']); $Params['country'] = isset($Person['PasportCountry']) ? $Person['PasportCountry'] : $Person['pCountry']; $Params['zip'] = $Person['pIndex']; break; case 'Juridical': #------------------------------------------------------------------------- $Params['name'] = SPrintF('%s %s %s', Translit($Person['dName']), Translit($Person['dLastname']), Translit($Person['dSourname'])); $Params['company'] = SPrintF('%s %s', Translit($Person['CompanyName']), Translit($Person['CompanyFormFull'])); $Params['address1'] = Translit(SPrintF('%s %s', $Person['jType'], $Person['jAddress'])); $Params['address2'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress'])); $Params['address3'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress'])); $Params['city'] = Translit($Person['jCity']); $Params['state'] = Translit($Person['jState']); $Params['country'] = Translit($Person['jCountry']); $Params['zip'] = $Person['jIndex']; break; default: return ERROR | @Trigger_Error(400); } #----------------------------------------------------------------------------- $Phone = $Person['Phone']; #----------------------------------------------------------------------------- if ($Phone) { #--------------------------------------------------------------------------- $Phone = Preg_Split('/\\s+/', $Phone); #--------------------------------------------------------------------------- $Params['telNoCc'] = Trim(Current($Phone), '+'); $Params['telNo'] = SPrintF('%s%s', Next($Phone), Next($Phone)); #--------------------------------------------------------------------------- Reset($Phone); #--------------------------------------------------------------------------- $Params['altTelNoCc'] = Trim(Current($Phone), '+'); $Params['altTelNo'] = SPrintF('%s%s', Next($Phone), Next($Phone)); } else { #--------------------------------------------------------------------------- $Params['telNoCc'] = ''; $Params['telNo'] = ''; $Params['altTelNoCc'] = ''; $Params['altTelNo'] = ''; } #----------------------------------------------------------------------------- $Fax = $Person['Fax']; #----------------------------------------------------------------------------- if ($Fax) { #--------------------------------------------------------------------------- $Fax = Preg_Split('/\\s+/', $Fax); #--------------------------------------------------------------------------- $Params['faxNoCc'] = Trim(Current($Fax), '+'); $Params['faxNo'] = SPrintF('%s%s', Next($Fax), Next($Fax)); } else { #--------------------------------------------------------------------------- $Params['faxNoCc'] = ''; $Params['faxNo'] = ''; } #----------------------------------------------------------------------------- $Params['customerLangPref'] = 'ru'; #----------------------------------------------------------------------------- Debug(Print_R($Params, TRUE)); #----------------------------------------------------------------------------- $Response = $AddCustomer->__SoapCall('addCustomer', $Params); #----------------------------------------------------------------------------- if (Is_SOAP_Fault($Response)) { #--------------------------------------------------------------------------- Debug($Response->faultstring); #--------------------------------------------------------------------------- return new gException('ANSWER_ERROR', 'Ошибка обращения к регистратору'); } #----------------------------------------------------------------------------- $CustomerID = $Response; #----------------------------------------------------------------------------- $Wsdl = System_Element('config/Wsdl/DomContact.wsdl'); if (Is_Error($Wsdl)) { return ERROR | @Trigger_Error(500); } #----------------------------------------------------------------------------- $DefaultContact = new SoapClient($Wsdl, array('exceptions' => 0)); #----------------------------------------------------------------------------- $Response = $DefaultContact->addDefaultContact($Settings['Login'], $Settings['Password'], 'reseller', 'ru', $Settings['ParentID'], $CustomerID); #----------------------------------------------------------------------------- if (Is_SOAP_Fault($Response)) { #--------------------------------------------------------------------------- Debug($Response->faultstring); #--------------------------------------------------------------------------- return new gException('ANSWER_ERROR', 'Ошибка обращения к регистратору'); } #----------------------------------------------------------------------------- return array('TicketID' => $CustomerID); }
function FindConfigElem(&$cfg_file, $elem_name) { $cfg_info = array(); $inside = 0; for ($i = 0; $i < Count($cfg_file); $i++) { $cfg_line = $cfg_file[$i]; $cfg_line = RTrim($cfg_line); $cfg_line = LTrim($cfg_line); if (!$cfg_line) { // Blank line continue; } elseif (Preg_Match("/^(\\/\\/|#)/", $cfg_line)) { //Comment line continue; } elseif (Preg_Match("/^(([[:alnum:]]+)\\s+({$elem_name})|{$elem_name})\$/i", $cfg_line, $matches)) { $next_line = RTrim($cfg_file[$i + 1]); if (!Preg_Match("/\\s*\\{\\s*/i", $next_line)) { // Not an elem line - maybe a property line with no spaces infront of it. continue; } //Print("Inside (0){$matches[0]} (1){$matches[1]} (2){$matches[2]} (3){$matches[3]}\n"); //It is inside the elem that it has been told to read. $inside = 1; } elseif ($inside) { if (Preg_Match("/^{/i", $cfg_line)) { //Ignore the { line continue; } elseif (Preg_Match("/^}/i", $cfg_line)) { //It reached the } line, which means it is done reading the elem. //Stop going through the rest of the file at this point. $inside = 0; break; } else { //It is still inside the elem's brackets. //Split the lines up into key value pairs. //Tuck the values into the array[key] $info = Preg_Split("/\\s+/", $cfg_line, 2, PREG_SPLIT_NO_EMPTY); $key = $info[0]; $value = $info[1]; if (!Is_Array($cfg_info[$key])) { // If cfg_info[key] is not already an array, // make it one so it can hold multiple values. $cfg_info[$key] = array(); } Array_Push($cfg_info[$key], $value); } } } if (Count($cfg_info) < 1) { return FALSE; } else { return $cfg_info; } }
#------------------------------------------------------------------------- $Attribs['jCity'] = $Attribs['City']; $Attribs['pCity'] = $Attribs['City']; $Attribs['CityEn'] = Translit($Attribs['City']); #------------------------------------------------------------------------- $Attribs['jAddress'] = Trim(Preg_Replace('/(ул|пр)\\./iu', '', $Attribs['jAddress'])); $Attribs['pAddress'] = Trim(Preg_Replace('/(ул|пр)\\./iu', '', $Attribs['jAddress'])); $Attribs['AddressEn'] = Translit($Attribs['jAddress']); #------------------------------------------------------------------------- $Attribs['jIndex'] = $Attribs['PostIndex']; $Attribs['pIndex'] = $Attribs['PostIndex']; #------------------------------------------------------------------------- #------------------------------------------------------------------------- $CompanyName = $Attribs['CompanyName']; #------------------------------------------------------------------------- $CompanyName = Preg_Split('/\\s+/', $CompanyName); #------------------------------------------------------------------------- $Attribs['Form'] = Current($CompanyName); #------------------------------------------------------------------------- unset($CompanyName[0]); #------------------------------------------------------------------------- $CompanyName = Implode(' ', $CompanyName); #------------------------------------------------------------------------- if (Preg_Match('/(общество\\sс\\sограниченной\\sответственностью)\\s(.+)/ui', $CompanyName, $Matches)) { #----------------------------------------------------------------------- $Attribs['Form'] = 'ООО'; #----------------------------------------------------------------------- $CompanyName = $Matches[2]; #----------------------------------------------------------------------- } elseif (Preg_Match('/(закрытое\\sакционерное\\sобщество)\\s(.+)/ui', $CompanyName, $Matches)) { #-----------------------------------------------------------------------
$EnCharMap = array("jo", "j", "c", "u", "k", "e", "n", "g", "sh", "sh", "z", "h", "'", "f", "u", "v", "a", "p", "r", "o", "l", "d", "zh", "je", "ja", "ch", "s", "m", "i", "t", "'", "b", "ju"); #------------------------------------------------------------------------------- # For transliteration russian char map $RuCharMap = array("ё", "й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х", "ъ", "ф", "ы", "в", "а", "п", "р", "о", "л", "д", "ж", "э", "я", "ч", "с", "м", "и", "т", "ь", "б", "ю"); #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- foreach (Preg_Split('/[\\s,]+/', $Text) as $Word) { #Debug(SPrintF('[comp/Formats/Edesk/Message/CheckFoul]: Word = "%s"',print_r($Word,true))); #------------------------------------------------------------------------------- $Word = Trim(Str_Replace($EnCharMap, $RuCharMap, Mb_StrToLower($Word, 'UTF-8'))); #------------------------------------------------------------------------------- if (Mb_StrLen($Word) > $Settings['FoulMaxLength']) { continue; } #------------------------------------------------------------------------------- foreach (Preg_Split('/\\s+/', $Regulars['Fouls']) as $Foul) { #------------------------------------------------------------------------------- $Foul = Trim($Foul); #Debug(SPrintF('[comp/Formats/Edesk/Message/CheckFoul]: Foul = "%s"',print_r($Foul,true))); #------------------------------------------------------------------------------- if (Preg_Match($Foul, $Word)) { #------------------------------------------------------------------------------- Debug(SPrintF('[comp/Formats/Edesk/Message/CheckFoul]: Foul found: "%s"', $Word)); return array('Word' => $Word); # нецензурщина детектед #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- continue; #------------------------------------------------------------------------------- }
} #------------------------------------------------------------------------------- $Result = $Link->Query(SPrintF('SET NAMES `%s`', $Charset)); if (Is_Error($Result)) { return $Link->GetError(); } #------------------------------------------------------------------------------- if (Is_Error($Link->SelectDB())) { return $Link->GetError(); } #------------------------------------------------------------------------------- $Query = 'SELECT * FROM `users`'; #------------------------------------------------------------------------------- if ($Users) { #----------------------------------------------------------------------------- $Users = Preg_Split('/\\s+/', $Users); #----------------------------------------------------------------------------- $Array = array(); #----------------------------------------------------------------------------- foreach ($Users as $User) { $Array[] = SPrintF("'%s'", $User); } #----------------------------------------------------------------------------- $Users = $Array; #----------------------------------------------------------------------------- $Query .= SPrintF(' WHERE `email` IN(%s)', Implode(',', $Users)); } #------------------------------------------------------------------------------- $Query .= ' LIMIT 90,100'; #------------------------------------------------------------------------------- $Result = $Link->Query($Query);
Debug(SPrintF('[comp/Tasks/ServersUpTime]: группы не соответствуют %s != %s', $Server['GroupName'], $Group)); #------------------------------------------------------------------------------- continue; #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- if (!isset($GLOBALS['TaskReturnInfo'][$Server['GroupName']])) { $GLOBALS['TaskReturnInfo'][$Server['GroupName']] = array(); } #------------------------------------------------------------------------------- $GLOBALS['TaskReturnInfo'][$Server['GroupName']][] = $Server['Address']; #------------------------------------------------------------------------------- if (StrLen($Server['Monitoring']) > 3) { #------------------------------------------------------------------------------- $Services = Preg_Split('/\\n+/', $Server['Monitoring']); #------------------------------------------------------------------------------- foreach ($Services as $Service) { #------------------------------------------------------------------------------- $Service = Explode('=', $Service); #------------------------------------------------------------------------------- $ServiceName = Current($Service); #------------------------------------------------------------------------------- $Port = IntVal(Next($Service)); #------------------------------------------------------------------------------- #Debug(SPrintF('[comp/Tasks/ServersUpTime]: connect to %s:%u',$Server['Address'],$Port)); #------------------------------------------------------------------------------- $Socket = @FsockOpen($Server['Address'], $Port, $nError, $sError, $Settings['SocketTimeout']); #------------------------------------------------------------------------------- if (!Is_Resource($Socket)) { #-------------------------------------------------------------------------------
return new gException('MANUAL_EXECUTION', 'Задание должно быть выполненно в ручную, либо активированно для автоматического выполнения'); } #--------------------------------------------------------------------------- $DOM = new DOM(); #--------------------------------------------------------------------------- $Links =& Links(); # Коллекция ссылок $Links['DOM'] =& $DOM; #--------------------------------------------------------------------------- if (Is_Error($DOM->Load('Window'))) { return ERROR | @Trigger_Error(500); } #--------------------------------------------------------------------------- $DOM->AddText('Title', 'Результат выполнения задачи'); #--------------------------------------------------------------------------- $Actions = Preg_Split("(\n\r|\n)", $Result); #--------------------------------------------------------------------------- for ($i = 0; $i < Count($Actions); $i++) { $Actions[$i] = WordWrap(HtmlSpecialChars($Actions[$i]), 120, "\n", TRUE); } #--------------------------------------------------------------------------- $DOM->AddChild('Into', new Tag('PRE', array('class' => 'Script'), Implode("\n", $Actions))); #--------------------------------------------------------------------------- if (Is_Error($DOM->Build(FALSE))) { return ERROR | @Trigger_Error(500); } #--------------------------------------------------------------------------- return array('Status' => 'Ok', 'DOM' => $DOM->Object); default: return ERROR | @Trigger_Error(101); }
function MasterName_Contract_Register($Settings, $PepsonID, $Person, $DomainZone) { /****************************************************************************/ $__args_types = array('array', 'string', 'array', 'string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $HTTP = array('Address' => $Settings['Address'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Charset' => 'CP1251', 'IsLogging' => $Settings['Params']['IsLogging']); #----------------------------------------------------------------------------- $Query = array(); #----------------------------------------------------------------------------- $Query[] = '[request]'; $Query[] = SPrintF('login: %s', $Settings['Login']); $Query[] = SPrintF('password: %s', $Settings['Password']); $Query[] = 'action: create_client'; #----------------------------------------------------------------------------- $RequestID = UniqID('ID'); #----------------------------------------------------------------------------- $Query[] = SPrintF('request-id: %s', $RequestID); #----------------------------------------------------------------------------- $Query[] = ''; #----------------------------------------------------------------------------- switch ($PepsonID) { case 'Natural': #------------------------------------------------------------------------- $Query[] = '[client]'; #------------------------------------------------------------------------- $Query[] = 'client-type: ФИЗЛИЦО'; $Query[] = $Person['PasportCountry'] != 'RU' ? 'non-resident:' : 'resident:'; #------------------------------------------------------------------------- $Query[] = SPrintF('person-r: %s %s %s', $Person['Sourname'], $Person['Name'], $Person['Lastname']); $Query[] = SPrintF('person: %s %s %s', Translit($Person['Name']), Mb_SubStr(Translit($Person['Lastname']), 0, 1), Translit($Person['Sourname'])); $Query[] = SPrintF('email: %s', $Person['Email']); #------------------------------------------------------------------------- $Phone = $Person['Phone']; #------------------------------------------------------------------------- $Query[] = SPrintF('phone: %s', $Phone); #------------------------------------------------------------------------- $Fax = $Person['Fax']; #------------------------------------------------------------------------- $Query[] = SPrintF('fax: %s', $Fax ? $Fax : $Phone); #------------------------------------------------------------------------- $BornDate = Explode('.', $Person['BornDate']); #------------------------------------------------------------------------- $Query[] = SPrintF('birth-date: %s-%s-%s', End($BornDate), Prev($BornDate), Prev($BornDate)); #------------------------------------------------------------------------- $PasportLine = Preg_Split('/^([0-9]{2})/', $Person['PasportLine'], -1, PREG_SPLIT_DELIM_CAPTURE); #------------------------------------------------------------------------- $Query[] = SPrintF('passport-series: %s %s', Next($PasportLine), Next($PasportLine)); $Query[] = SPrintF('passport-number: %s', $Person['PasportNum']); #------------------------------------------------------------------------- $PasportDate = Explode('.', $Person['PasportDate']); #------------------------------------------------------------------------- $Query[] = SPrintF('passport-date: %s-%s-%s', End($PasportDate), Prev($PasportDate), Prev($PasportDate)); $Query[] = SPrintF('passport-org: %s', $Person['PasportWhom']); #------------------------------------------------------------------------- $Query[] = SPrintF('post-country: %s', $Person['pCountry']); $Query[] = SPrintF('post-region: %s', $Person['pState']); $Query[] = SPrintF('post-zip-code: %s', $Person['pIndex']); $Query[] = SPrintF('post-city: %s', $Person['pCity']); $Query[] = SPrintF('post-street: %s %s, %s', $Person['pType'], $Person['pAddress'], $Person['pRecipient']); #------------------------------------------------------------------------- $Query[] = SPrintF('reg-country: %s', $Person['pCountry']); $Query[] = SPrintF('reg-region: %s', $Person['pState']); $Query[] = SPrintF('reg-city: %s', $Person['pCity']); $Query[] = SPrintF('reg-street: %s %s', $Person['pType'], $Person['pAddress']); break; case 'Juridical': #------------------------------------------------------------------------- $Query[] = '[client]'; #------------------------------------------------------------------------- $Query[] = 'client-type: ЮРЛИЦО'; $Query[] = 'resident:'; #------------------------------------------------------------------------- $Query[] = SPrintF('ownership: %s', $Person['CompanyFormFull']); $Query[] = SPrintF('org-r: %s', $Person['CompanyName']); #------------------------------------------------------------------------- $Query[] = SPrintF('org: %s %s', Translit($Person['CompanyName']), Translit($Person['CompanyFormFull'])); $Query[] = SPrintF('email: %s', $Person['Email']); #------------------------------------------------------------------------- $Phone = $Person['Phone']; #------------------------------------------------------------------------- $Query[] = SPrintF('phone: %s', $Phone); #------------------------------------------------------------------------- $Fax = $Person['Fax']; #------------------------------------------------------------------------- $Query[] = SPrintF('fax: %s', $Fax ? $Fax : $Phone); $Query[] = SPrintF('contact: %s %s %s', $Person['dSourname'], $Person['dName'], $Person['dLastname']); $Query[] = SPrintF('inn: %s', $Person['Inn']); $Query[] = SPrintF('kpp: %s', $Person['Kpp']); #------------------------------------------------------------------------- $Query[] = SPrintF('post-country: %s', $Person['pCountry']); $Query[] = SPrintF('post-zip-code: %s', $Person['pIndex']); $Query[] = SPrintF('post-region: %s', $Person['pState']); $Query[] = SPrintF('post-city: %s', $Person['pCity']); $Query[] = SPrintF('post-street: %s %s, %s "%s"', $Person['pType'], $Person['pAddress'], $Person['CompanyFormFull'], $Person['CompanyName']); #------------------------------------------------------------------------- $Query[] = SPrintF('jur-country: %s', $Person['jCountry']); $Query[] = SPrintF('jur-zip-code: %s', $Person['jIndex']); $Query[] = SPrintF('jur-region: %s', $Person['jState']); $Query[] = SPrintF('jur-city: %s', $Person['jCity']); $Query[] = SPrintF('jur-street: %s %s', $Person['jType'], $Person['jAddress']); #------------------------------------------------------------------------- $Query[] = SPrintF('real-country: %s', $Person['jCountry']); $Query[] = SPrintF('real-zip-code: %s', $Person['jIndex']); $Query[] = SPrintF('real-region: %s', $Person['jState']); $Query[] = SPrintF('real-city: %s', $Person['jCity']); $Query[] = SPrintF('real-street: %s %s', $Person['pType'], $Person['jAddress']); break; default: return new gException('WRONG_PROFILE_ID', 'Неверный идентификатор профиля'); } #----------------------------------------------------------------------------- $Query = array('request' => Implode("\n", $Query)); #----------------------------------------------------------------------------- $Result = HTTP_Send('/partner_gateway', $HTTP, array(), $Query); if (Is_Error($Result)) { return ERROR | @Trigger_Error('[MasterName_Contract_Register]:не удалось выполнить запрос к серверу'); } #----------------------------------------------------------------------------- $Result = Trim($Result['Body']); #----------------------------------------------------------------------------- if (Preg_Match('/status:\\s([0-9]+)\\s/', $Result, $CodeID)) { #--------------------------------------------------------------------------- $CodeID = Next($CodeID); #--------------------------------------------------------------------------- switch ($CodeID) { case '200': # No more... # No more... case '201': # No more... # No more... case '202': return array('TicketID' => $RequestID); case '203': return new gException('REQUEST_FAILED', 'Обработка запроса завершилась с ошибкой'); case '400': return new gException('BAD_REQUEST', 'Неверный формат запроса'); case '401': return new gException('AUTH_ERROR', 'Ошибка авторизации'); case '402': return new gException('DATA_ERROR', 'Ошибка в данных запроса'); case '403': return new gException('FORBIDDEN', 'Доступ к запрашиваемому объекту запрещен'); case '404': return new gException('NOT_FOUND', 'Запрашиваемый объект не найден'); case '405': return new gException('INVALID_REQUEST', 'Невозможно выполнить запрос'); case '500': return new gException('SERVER_ERROR', 'Внутренняя ошибка сервера'); default: return new gException('WRONG_ERROR', 'Неизвестный статус ошибки'); } } #----------------------------------------------------------------------------- return new gException('WRONG_ANSWER', $Result); }
return ERROR | @Trigger_Error(500); case 'exception': return TRUE; case 'array': break; default: return ERROR | @Trigger_Error(101); } #----------------------------------------------------------------------------- for ($i = 0; $i < Count($Services); $i++) { $Query = DB_Query(SPrintF("SHOW TABLES LIKE '%s%%OrdersOwners'", $Services[$i]['Code'])); $Row = MySQL::Result($Query); foreach (Array_Keys($Row[0]) as $Key) { $Services[$i]['View'] = $Row[0][$Key]; } $View = Preg_Split('/Owner/', $Services[$i]['View']); $Services[$i]['Table'] = Current($View); } #----------------------------------------------------------------------------- CacheManager::add($CacheID, $Services, 600); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- #Debug("[Tasks/GC/EraseDeletedOrders]: " . print_r($Services,true)); #------------------------------------------------------------------------------- for ($i = 0; $i < Count($Services); $i++) { Debug(SPrintF("[Tasks/GC/EraseDeletedOrders]: Код текущей услуги - %s", $Services[$i]['Code'])); #----------------------------------------------------------------------------- $Where = SPrintF("`StatusID` = 'Deleted' AND `StatusDate` < UNIX_TIMESTAMP( ) - %d *86400", $Params['Invoices']['DaysBeforeErase']); #----------------------------------------------------------------------------- $Orders = DB_Select($Services[$i]['View'], array('ID', 'OrderID', 'UserID'), array('Where' => $Where));
function RegRu_Domain_Register($Settings, $DomainName, $DomainZone, $Years, $Ns1Name, $Ns1IP, $Ns2Name, $Ns2IP, $Ns3Name, $Ns3IP, $Ns4Name, $Ns4IP, $ContractID = '', $IsPrivateWhoIs, $PepsonID = 'Default', $Person = array()) { /****************************************************************************/ $__args_types = array('array', 'string', 'string', 'integer', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'boolean', 'string', 'string', 'array'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $HTTP = RegRu_Build_HTTP($Settings); #----------------------------------------------------------------------------- $Domain = Mb_StrToLower(SPrintF('%s.%s', $DomainName, $DomainZone), 'UTF-8'); #----------------------------------------------------------------------------- $Query = array('username' => $Settings['Login'], 'password' => $Settings['Password'], 'domain_name' => $Domain, 'enduser_ip' => '127.0.0.1', 'pay_type' => 'prepay', 'private_person_flag' => $IsPrivateWhoIs); #----------------------------------------------------------------------------- $Query['period'] = $Years; #----------------------------------------------------------------------------- if (In_Array($DomainZone, array('ru', 'su', 'рф'))) { #--------------------------------------------------------------------------- switch ($PepsonID) { case 'Natural': #----------------------------------------------------------------------- $Query['person'] = SPrintF('%s %s %s', Translit($Person['Name']), Mb_SubStr(Translit($Person['Lastname']), 0, 1), Translit($Person['Sourname'])); $Query['private_person_flag'] = 1; $Query['person_r'] = SPrintF('%s %s %s', $Person['Sourname'], $Person['Name'], $Person['Lastname']); $Query['passport'] = SPrintF('%s %s выдан %s %s', $Person['PasportLine'], $Person['PasportNum'], $Person['PasportWhom'], $Person['PasportDate']); $Query['birth_date'] = $Person['BornDate']; $Query['country'] = isset($Person['PasportCountry']) ? $Person['PasportCountry'] : $Person['pCountry']; $Query['p_addr'] = SPrintF('%s, %s, %s, %s %s, %s', $Person['pIndex'], $Person['pState'], $Person['pCity'], $Person['pType'], $Person['pAddress'], $Person['pRecipient']); $Query['phone'] = $Person['Phone']; $Query['sms_security_number'] = $Person['CellPhone']; $Query['fax'] = $Person['Fax']; $Query['e_mail'] = $Person['Email']; break; case 'Juridical': #----------------------------------------------------------------------- $Query['org'] = SPrintF('%s %s', Translit($Person['CompanyName']), Translit($Person['CompanyFormFull'])); $Query['org_r'] = SPrintF('%s "%s"', $Person['CompanyFormFull'], $Person['CompanyName']); $Query['code'] = $Person['Inn']; $Query['kpp'] = $Person['Kpp']; $Query['country'] = $Person['jCountry']; $Query['address_r'] = SPrintF('%s, %s, %s, %s %s', $Person['jIndex'], $Person['jState'], $Person['jCity'], $Person['jType'], $Person['jAddress']); $Query['p_addr'] = SPrintF('%s, %s, %s, %s %s, %s "%s"', $Person['pIndex'], $Person['pState'], $Person['pCity'], $Person['pType'], $Person['pAddress'], $Person['CompanyFormFull'], $Person['CompanyName']); $Query['phone'] = $Person['Phone']; $Query['sms_security_number'] = $Person['CellPhone']; $Query['fax'] = $Person['Fax']; $Query['e_mail'] = $Person['Email']; break; default: return new gException('WRONG_PROFILE_ID', 'Неверный идентификатор профиля'); } #--------------------------------------------------------------------------- } elseif (In_Array($DomainZone, array('info', 'biz', 'org', 'com', 'net', 'be', 'cc', 'tv', 'pro', 'site'))) { #--------------------------------------------------------------------------- switch ($PepsonID) { case 'Natural': #----------------------------------------------------------------------- $Query['o_company'] = 'Private person'; $Query['a_company'] = 'Private person'; $Query['t_company'] = 'Private person'; $Query['b_company'] = 'Private person'; #----------------------------------------------------------------------- $Query['o_country_code'] = $Person['pCountry']; $Query['a_country_code'] = $Person['pCountry']; $Query['t_country_code'] = $Person['pCountry']; $Query['b_country_code'] = $Person['pCountry']; #----------------------------------------------------------------------- $Query['o_postcode'] = $Person['pIndex']; $Query['a_postcode'] = $Person['pIndex']; $Query['t_postcode'] = $Person['pIndex']; $Query['b_postcode'] = $Person['pIndex']; #----------------------------------------------------------------------- $Query['o_first_name'] = Translit($Person['Name']); $Query['a_first_name'] = Translit($Person['Name']); $Query['t_first_name'] = Translit($Person['Name']); $Query['b_first_name'] = Translit($Person['Name']); #----------------------------------------------------------------------- $Query['o_last_name'] = Translit($Person['Sourname']); $Query['a_last_name'] = Translit($Person['Sourname']); $Query['t_last_name'] = Translit($Person['Sourname']); $Query['b_last_name'] = Translit($Person['Sourname']); #----------------------------------------------------------------------- $Query['o_email'] = $Person['Email']; $Query['a_email'] = $Person['Email']; $Query['t_email'] = $Person['Email']; $Query['b_email'] = $Person['Email']; #----------------------------------------------------------------------- $Query['o_addr'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress'])); $Query['a_addr'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress'])); $Query['t_addr'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress'])); $Query['b_addr'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress'])); #----------------------------------------------------------------------- $Query['o_city'] = Translit($Person['pCity']); $Query['a_city'] = Translit($Person['pCity']); $Query['t_city'] = Translit($Person['pCity']); $Query['b_city'] = Translit($Person['pCity']); #----------------------------------------------------------------------- $Query['o_state'] = Translit($Person['pState']); $Query['a_state'] = Translit($Person['pState']); $Query['t_state'] = Translit($Person['pState']); $Query['b_state'] = Translit($Person['pState']); break; case 'Juridical': #----------------------------------------------------------------------- $CompanyEn = SPrintF('%s %s', Translit($Person['CompanyName']), Translit($Person['CompanyFormFull'])); #----------------------------------------------------------------------- $Query['o_company'] = $CompanyEn; $Query['a_company'] = $CompanyEn; $Query['t_company'] = $CompanyEn; $Query['b_company'] = $CompanyEn; #----------------------------------------------------------------------- $Query['o_country_code'] = $Person['jCountry']; $Query['a_country_code'] = $Person['jCountry']; $Query['t_country_code'] = $Person['jCountry']; $Query['b_country_code'] = $Person['jCountry']; #----------------------------------------------------------------------- $Query['o_postcode'] = $Person['jIndex']; $Query['a_postcode'] = $Person['jIndex']; $Query['t_postcode'] = $Person['jIndex']; $Query['b_postcode'] = $Person['jIndex']; #----------------------------------------------------------------------- $Query['o_first_name'] = Translit($Person['dName']); $Query['a_first_name'] = Translit($Person['dName']); $Query['t_first_name'] = Translit($Person['dName']); $Query['b_first_name'] = Translit($Person['dName']); #----------------------------------------------------------------------- $Query['o_last_name'] = Translit($Person['dSourname']); $Query['a_last_name'] = Translit($Person['dSourname']); $Query['t_last_name'] = Translit($Person['dSourname']); $Query['b_last_name'] = Translit($Person['dSourname']); #----------------------------------------------------------------------- $Query['o_email'] = $Person['Email']; $Query['a_email'] = $Person['Email']; $Query['t_email'] = $Person['Email']; $Query['b_email'] = $Person['Email']; #----------------------------------------------------------------------- $Query['o_addr'] = Translit(SPrintF('%s %s', $Person['jType'], $Person['jAddress'])); $Query['a_addr'] = Translit(SPrintF('%s %s', $Person['jType'], $Person['jAddress'])); $Query['t_addr'] = Translit(SPrintF('%s %s', $Person['jType'], $Person['jAddress'])); $Query['b_addr'] = Translit(SPrintF('%s %s', $Person['jType'], $Person['jAddress'])); #----------------------------------------------------------------------- $Query['o_city'] = Translit($Person['jCity']); $Query['a_city'] = Translit($Person['jCity']); $Query['t_city'] = Translit($Person['jCity']); $Query['b_city'] = Translit($Person['jCity']); #----------------------------------------------------------------------- $Query['o_state'] = Translit($Person['jState']); $Query['a_state'] = Translit($Person['jState']); $Query['t_state'] = Translit($Person['jState']); $Query['b_state'] = Translit($Person['jState']); break; default: return new gException('WRONG_PERSON_TYPE_ID', 'Неверный идентификатор типа персоны'); } #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- if ($DomainZone == 'pro') { $Query['pro_profession'] = 'Other'; } #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- $Phone = $Person['Phone']; #--------------------------------------------------------------------------- if ($Phone) { #------------------------------------------------------------------------- $Phone = Preg_Split('/\\s+/', $Phone); #------------------------------------------------------------------------- $Phone = SPrintF('%s.%s%s', Current($Phone), Next($Phone), Next($Phone)); #------------------------------------------------------------------------- $Query['o_phone'] = $Phone; $Query['a_phone'] = $Phone; $Query['t_phone'] = $Phone; $Query['b_phone'] = $Phone; } else { #------------------------------------------------------------------------- $Query['o_phone'] = ''; $Query['a_phone'] = ''; $Query['t_phone'] = ''; $Query['b_phone'] = ''; } #--------------------------------------------------------------------------- $Fax = $Person['Fax']; #--------------------------------------------------------------------------- if ($Fax) { #------------------------------------------------------------------------- $Fax = Preg_Split('/\\s+/', $Fax); #------------------------------------------------------------------------- $Fax = SPrintF('%s.%s%s', Current($Fax), Next($Fax), Next($Fax)); #------------------------------------------------------------------------- $Query['o_fax'] = $Fax; $Query['a_fax'] = $Fax; $Query['t_fax'] = $Fax; $Query['b_fax'] = $Fax; } else { #------------------------------------------------------------------------- $Query['o_fax'] = ''; $Query['a_fax'] = ''; $Query['t_fax'] = ''; $Query['b_fax'] = ''; } } else { return new gException('WRONG_ZONE_NAME', 'Указанная зона не поддерживается в автоматическом режиме'); } #----------------------------------------------------------------------------- $Query['ns0'] = $Ns1Name; $Query['ns1'] = $Ns2Name; #----------------------------------------------------------------------------- if ($Ns1IP && $Ns2IP) { #--------------------------------------------------------------------------- $Query['ns0ip'] = $Ns1IP; $Query['ns1ip'] = $Ns2IP; } #----------------------------------------------------------------------------- $Settings['PrefixAPI'] = SprintF("https://api.reg.ru/api/regru2/%s", "domain/create"); #----------------------------------------------------------------------------- $Result = HTTP_Send($Settings['PrefixAPI'], $HTTP, array(), $Query); if (Is_Error($Result)) { return ERROR | @Trigger_Error('[RegRu_Domain_Register]: не удалось выполнить запрос к серверу'); } #----------------------------------------------------------------------------- $Result = Trim($Result['Body']); #----------------------------------------------------------------------------- $Result = Json_Decode($Result, TRUE); #----------------------------------------------------------------------------- if ($Result['result'] == 'success') { if (isset($Result['error_code'])) { return new gException('REGISTRATOR_ERROR_1', $Result['error_code']); } else { foreach (Array_Keys($Result['answer']) as $Key) { Debug(SPrintF("[RegRu_Answer::Domain_Register]: %s => %s", $Key, $Result['answer'][$Key])); } #--------------------------------------------------------------------------- if ($Result['answer']['dname'] == $Domain) { return array('TicketID' => (int) $Result['answer']['service_id']); #--------------------------------------------------------------------------- } } } #----------------------------------------------------------------------------- if ($Result['result'] == 'error') { return new gException('REGISTRATOR_ERROR', 'Регистратор вернул ошибку'); } #----------------------------------------------------------------------------- return new gException('WRONG_ANSWER', $Result); }
function WhoIs_Check($DomainName, $ZoneName, $IsAvalible = FALSE) { #------------------------------------------------------------------------------- Debug(SPrintF('[system/libs/WhoIs]: run function WhoIs_Check, Domain = %s.%s', $DomainName, $ZoneName)); #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $CacheID = SPrintF('WhoIs-%s.%s', $DomainName, $ZoneName); #------------------------------------------------------------------------------- $Answer = CacheManager::get($CacheID); #------------------------------------------------------------------------------- if (!$Answer) { #------------------------------------------------------------------------------- # смотрим доменную зону, на предмет того использовать ли данные whois сервера, или юзать запросы к регистратору $DomainZones = System_XML('config/DomainZones.xml'); if (Is_Error($DomainZones)) { return ERROR | @Trigger_Error('[comp/www/API/WhoIs]: не удалось загрузить базу WhoIs серверов'); } #------------------------------------------------------------------------------- $IsSuppoted = FALSE; #------------------------------------------------------------------------------- foreach ($DomainZones as $Zone) { #------------------------------------------------------------------------------- if ($Zone['Name'] == $ZoneName) { #------------------------------------------------------------------------------- $IsSuppoted = TRUE; #------------------------------------------------------------------------------- break; #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- if (!$IsSuppoted || $Zone['IsUseRegistratorWhoIs']) { #------------------------------------------------------------------------------- if (!$IsSuppoted) { Debug(SPrintF('[comp/www/API/WhoIs]: доменная зона не поддерживается')); } #------------------------------------------------------------------------------- if ($IsSuppoted && $Zone['IsUseRegistratorWhoIs']) { Debug(SPrintF('[comp/www/API/WhoIs]: принудительное использование WhoIs регистратора')); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # чекаем доменную зону $Regulars = Regulars(); #------------------------------------------------------------------------------- if (!Preg_Match($Regulars['DomainZone'], $ZoneName)) { return ERROR | @Trigger_Error(SPrintF('[comp/www/API/WhoIs]: неверная доменная зона (%s)', $ZoneName)); } #------------------------------------------------------------------------------- # достаём список серверов на которых есть такой тариф $Servers = DB_Select('DomainSchemes', array('ServerID'), array('Where' => SPrintF('`Name` = "%s"', $ZoneName))); #------------------------------------------------------------------------------- switch (ValueOf($Servers)) { case 'error': return ERROR | @Trigger_Error(500); case 'exception': return new gException('REGISTRATOR_SERVER_NOT_FOUND', 'Не найдены активные сервера регистраторов'); case 'array': #------------------------------------------------------------------------------- $Array = array(); #------------------------------------------------------------------------------- foreach ($Servers as $Server) { $Array[] = $Server['ServerID']; } #------------------------------------------------------------------------------- break; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- default: return ERROR | @Trigger_Error(101); } #------------------------------------------------------------------------------- # достаём список активных серверов регистраторов $Servers = DB_Select('Servers', array('ID', 'Address', 'Params'), array('Where' => array(SPrintF('`ID` IN (%s)', Implode(',', $Array)), '`IsActive` = "yes"'), 'SortOn' => 'Address')); #------------------------------------------------------------------------------- switch (ValueOf($Servers)) { case 'error': return ERROR | @Trigger_Error(500); case 'exception': return new gException('REGISTRATOR_SERVER_NOT_FOUND', 'Не найдены активные сервера регистраторов'); case 'array': break; default: return ERROR | @Trigger_Error(101); } #------------------------------------------------------------------------------- # перебираем регистраторов $UseServer = FALSE; #------------------------------------------------------------------------------- foreach ($Servers as $iServer) { #------------------------------------------------------------------------------- # если это не проверка доступности и в настройках сервера не стоит галка про получение WhoIs - пропускаем if (!$IsAvalible) { if (!$iServer['Params']['IsFetchWhoIs']) { continue; } } #------------------------------------------------------------------------------- # достаём использованные запросы к регистратору, на данную минуту $RatelimitID = SPrintF('ratelimit-%s-%s-00', $iServer['Address'], Date('H-i')); #------------------------------------------------------------------------------- $Ratelimit = CacheManager::get($RatelimitID); #------------------------------------------------------------------------------- # если из кэша что-то досталось и оно больше разрешённой частоты запросов - пропускаем цикл if ($Ratelimit && $Ratelimit >= $iServer['Params']['RatelimitAPI']) { #------------------------------------------------------------------------------- Debug(SPrintF('[comp/www/API/WhoIs]: превышена частота запросов к серверу %s (разрешено %u, использовано %u)', $iServer['Address'], $iServer['Params']['RatelimitAPI'], $Ratelimit)); #------------------------------------------------------------------------------- continue; #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- # сохраняем, на пару минут, в кэш новое число запросов к регистратору CacheManager::add($RatelimitID, IntVal($Ratelimit) + 1, 120); #------------------------------------------------------------------------------- $UseServer = $iServer; #------------------------------------------------------------------------------- break; #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- # если не задан сервер - частота превышена для всех серверов if (!$UseServer) { return new gException('REGISTRATOR_SERVER_RATELIMIT', 'Превышена максимальная частота запросов к интерфейсу регистратора'); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # выбираем сервер регистратора if (Is_Error(System_Load('classes/DomainServer.class.php'))) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- $Server = new DomainServer(); #------------------------------------------------------------------------------- $IsSelected = $Server->Select((int) $UseServer['ID']); #------------------------------------------------------------------------------- switch (ValueOf($IsSelected)) { case 'error': return ERROR | @Trigger_Error(500); case 'exception': return new gException('CANNOT_SELECT_REGISTRATOR', 'Не удалось выбрать регистратора'); case 'true': break; default: return ERROR | @Trigger_Error(101); } #------------------------------------------------------------------------------- # делаем запрос к API - функция в зависимости от $IsAvalible if ($IsAvalible) { #------------------------------------------------------------------------------- $DomainCheck = $Server->DomainCheck($DomainName, $ZoneName); #------------------------------------------------------------------------------- switch (ValueOf($DomainCheck)) { case 'error': return ERROR | @Trigger_Error(500); case 'exception': return ERROR | @Trigger_Error(400); case 'true': return TRUE; case 'false': return array(); case 'array': break; default: return ERROR | @Trigger_Error(101); } #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- $DomainWhoIs = $Server->DomainWhoIs($DomainName, $ZoneName); #------------------------------------------------------------------------------- switch (ValueOf($DomainWhoIs)) { case 'error': return ERROR | @Trigger_Error(500); case 'exception': # a функции нет ... вылезаем на обычную проверку whois break; case 'true': return TRUE; case 'string': #------------------------------------------------------------------------------- CacheManager::add($CacheID, $DomainWhoIs, 1800); #------------------------------------------------------------------------------- break; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- default: return ERROR | @Trigger_Error(101); } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $Config = Config(); #------------------------------------------------------------------------------- $UseSystemApplication = $Config['Other']['Libs']['WhoIs']['UseSystemApplication']; #------------------------------------------------------------------------------- $Regulars = Regulars(); #------------------------------------------------------------------------------- if (!Preg_Match($Regulars['DomainName'], $DomainName)) { return new gException('WRONG_DOMAIN_NAME', 'Неверное доменное имя'); } #------------------------------------------------------------------------------- $DomainZones = System_XML('config/DomainZones.xml'); if (Is_Error($DomainZones)) { return ERROR | @Trigger_Error('[WhoIs_Check]: не удалось загрузить базу WhoIs серверов'); } #------------------------------------------------------------------------------- $IsSuppoted = FALSE; #------------------------------------------------------------------------------- foreach ($DomainZones as $DomainZone) { #------------------------------------------------------------------------------- if ($DomainZone['Name'] == $ZoneName) { #------------------------------------------------------------------------------- $IsSuppoted = TRUE; #------------------------------------------------------------------------------- break; #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- if (!$IsSuppoted && !isset($DomainWhoIs)) { return FALSE; } #------------------------------------------------------------------------------- if (Mb_StrLen($DomainName) < ($MinChars = $DomainZone['MinChars'])) { return new gException('WRONG_DOMAIN_NAME_LENGTH', SPrintF('Длина доменного имени должна быть не менее %u символа(ов)', $MinChars)); } #------------------------------------------------------------------------------- $Domain = SPrintF('%s.%s', $DomainName, $DomainZone['Name']); #------------------------------------------------------------------------------- $Answer = CacheManager::get($CacheID); #------------------------------------------------------------------------------- if (!$Answer) { #------------------------------------------------------------------------------- $IDNAConverter = new IDNAConvert(); #------------------------------------------------------------------------------- if ($UseSystemApplication) { #------------------------------------------------------------------------------- $IsExec = Exec(SPrintF('whois %s', $IDNAConverter->encode($Domain)), $Answer); #------------------------------------------------------------------------------- $Answer = Implode("\n", $Answer); #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- $Socket = @FsockOpen($DomainZone['Server'], 43, $nError, $sError, 5); #------------------------------------------------------------------------------- if (!$Socket) { return ERROR | @Trigger_Error('[WhoIs_Check]: ошибка соединения с сервером WhoIs'); } #------------------------------------------------------------------------------- if (!@Fputs($Socket, SPrintF("%s\r\n", $IDNAConverter->encode($Domain)))) { return ERROR | @Trigger_Error('[WhoIs_Check]: ошибка работы с серверов WhoIs'); } #------------------------------------------------------------------------------- $Answer = ''; #------------------------------------------------------------------------------- do { #------------------------------------------------------------------------------- $Line = @Fgets($Socket, 10); #------------------------------------------------------------------------------- $Answer .= $Line; #------------------------------------------------------------------------------- } while ($Line); #------------------------------------------------------------------------------- Fclose($Socket); #------------------------------------------------------------------------------- CacheManager::add($CacheID, $Answer, 1800); #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- Debug(SPrintF('[system/libs/WhoIs.php]: Answer = %s', print_r($Answer, true))); #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- if (Preg_Match(SPrintF('/%s/', $DomainZone['Available']), $Answer)) { return TRUE; } #------------------------------------------------------------------------------- if (Preg_Match(SPrintF('/%s/', $DomainZone['NotAvailable']), $Answer)) { return new gException('DOMAIN_NOT_AVAILABLE', 'Доменное имя не доступно для регистрации'); } #------------------------------------------------------------------------------- $Result = array('Info' => Preg_Replace('/\\n\\s+\\n/sU', "\n", Preg_Replace('/\\%.+\\n/sU', '', $Answer)), 'ExpirationDate' => 0); #------------------------------------------------------------------------------- $ExpirationDate = $DomainZone['ExpirationDate']; #------------------------------------------------------------------------------- if ($ExpirationDate) { #------------------------------------------------------------------------------- if (Preg_Match(SPrintF('/%s/', $ExpirationDate), $Answer, $Mathes)) { #------------------------------------------------------------------------------- if (Count($Mathes) < 2) { return ERROR | @Trigger_Error('[WhoIs_Check]: шаблон поиска даты окончания задан неверно'); } #------------------------------------------------------------------------------- $ExpirationDate = $Mathes[1]; #------------------------------------------------------------------------------- $Months = array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'); #------------------------------------------------------------------------------- if (Preg_Match('/^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}$/', $ExpirationDate)) { #------------------------------------------------------------------------------- $Date = Array_Combine(array('Year', 'Month', 'Day'), Explode('.', $ExpirationDate)); #------------------------------------------------------------------------------- $ExpirationDate = MkTime(0, 0, 0, $Date['Month'], $Date['Day'], $Date['Year']); #------------------------------------------------------------------------------- } elseif (Preg_Match('/^[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}$/', $ExpirationDate)) { #------------------------------------------------------------------------------- $Date = Array_Combine(array('Year', 'Month', 'Day'), Explode('-', $ExpirationDate)); #------------------------------------------------------------------------------- $ExpirationDate = MkTime(0, 0, 0, $Date['Month'], $Date['Day'], $Date['Year']); #------------------------------------------------------------------------------- } elseif (Preg_Match('/^[0-9]{2}\\-[a-zA-Z]{3}\\-[0-9]{4}$/', $ExpirationDate)) { #------------------------------------------------------------------------------- $Date = Array_Combine(array('Day', 'Month', 'Year'), Explode('-', $ExpirationDate)); #------------------------------------------------------------------------------- $Month = Array_Search(StrToLower($Date['Month']), $Months); #------------------------------------------------------------------------------- $ExpirationDate = MkTime(0, 0, 0, $Month + 1, $Date['Day'], $Date['Year']); #------------------------------------------------------------------------------- } elseif (Preg_Match('/^[0-9]{2}\\s[a-zA-Z]{2,10}\\s[0-9]{4}$/', $ExpirationDate)) { #------------------------------------------------------------------------------- $Months = array('january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'octember', 'november', 'decemeber'); #------------------------------------------------------------------------------- $Date = Array_Combine(array('Day', 'Month', 'Year'), Preg_Split('/\\s+/', $ExpirationDate)); #------------------------------------------------------------------------------- $Month = Array_Search(StrToLower($Date['Month']), $Months); #------------------------------------------------------------------------------- $ExpirationDate = MkTime(0, 0, 0, $Month + 1, $Date['Day'], $Date['Year']); #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- $Date = Array_Combine(array('Week', 'Month', 'Day', 'Time', 'GMT', 'Year'), Preg_Split('/\\s+/', $ExpirationDate)); #------------------------------------------------------------------------------- $Month = Array_Search(StrToLower($Date['Month']), $Months); #------------------------------------------------------------------------------- $ExpirationDate = MkTime(0, 0, 0, $Month + 1, $Date['Day'], $Date['Year']); #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- $Result['ExpirationDate'] = $ExpirationDate; #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- $NsName = $DomainZone['NsName']; #------------------------------------------------------------------------------- if ($NsName) { #------------------------------------------------------------------------------- if (Preg_Match_All(SPrintF('/%s/', $NsName), $Answer, $Mathes)) { #------------------------------------------------------------------------------- if (Count($Mathes) < 2) { return ERROR | @Trigger_Error('[WhoIs_Check]: шаблон поиска именных серверов задан неверно'); } #------------------------------------------------------------------------------- $NsNames = $Mathes[1]; #------------------------------------------------------------------------------- for ($i = 0; $i < Count($NsNames); $i++) { #------------------------------------------------------------------------------- $NsName = Trim(StrToLower($NsNames[$i]), '.'); #------------------------------------------------------------------------------- $Result[SPrintF('Ns%uName', $i + 1)] = $NsName; #------------------------------------------------------------------------------- if ($NsName) { #------------------------------------------------------------------------------- if (Mb_SubStr($NsName, -Mb_StrLen($Domain)) == $Domain) { #------------------------------------------------------------------------------- $IP = GetHostByName($NsName); #------------------------------------------------------------------------------- if ($IP != $NsName) { $Result[SPrintF('Ns%uIP', $i + 1)] = $IP; } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- $Registrar = $DomainZone['Registrar']; #------------------------------------------------------------------------------- if ($Registrar) { #------------------------------------------------------------------------------- if (Preg_Match(SPrintF('/%s/', $Registrar), $Answer, $Mathes)) { #------------------------------------------------------------------------------- if (Count($Mathes) < 2) { return ERROR | @Trigger_Error('[WhoIs_Check]: шаблон поиска регистратора серверов задан неверно'); } #------------------------------------------------------------------------------- $Registrar = Next($Mathes); #------------------------------------------------------------------------------- $Result['Registrar'] = $Registrar; #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- return $Result; #------------------------------------------------------------------------------- }
case 'exception': # No more... break; case 'array': #--------------------------------------------------------------------------- foreach ($Profiles as $Profile) { #------------------------------------------------------------------------- $Attribs = $Profile['Attribs']; #------------------------------------------------------------------------- if (isset($Attribs['dSourname'])) { continue; } #------------------------------------------------------------------------- $Director = $Attribs['Director']; #------------------------------------------------------------------------- $Director = Preg_Split('/\\s+/', $Director); #------------------------------------------------------------------------- $Attribs['dSourname'] = Current($Director); $Attribs['dName'] = Next($Director); $Attribs['dLastname'] = Next($Director); #------------------------------------------------------------------------- $Attribs['NameEn'] = Translit($Attribs['dName']); $Attribs['LastnameEn'] = Translit(Mb_SubStr($Attribs['dLastname'], 0, 1)); $Attribs['SournameEn'] = Translit($Attribs['dSourname']); #------------------------------------------------------------------------- #------------------------------------------------------------------------- $Attribs['jCountry'] = $Attribs['Country']; $Attribs['pCountry'] = $Attribs['Country']; #------------------------------------------------------------------------- $Attribs['jState'] = $Attribs['State']; $Attribs['pState'] = $Attribs['State'];
function Build_Query($Query = array(), $Params) { #------------------------------------------------------------------------------- if (In_Array($Params['DomainZone'], array('ru', 'su', 'рф'))) { #------------------------------------------------------------------------------- switch ($Params['PersonID']) { case 'Natural': #------------------------------------------------------------------------------- $Query['person'] = SPrintF('%s %s %s', Translit($Params['Person']['Name']), Mb_SubStr(Translit($Params['Person']['Lastname']), 0, 1), Translit($Params['Person']['Sourname'])); $Query['private_person'] = $Params['IsPrivateWhoIs'] ? '1' : '0'; $Query['person_r'] = SPrintF('%s %s %s', $Params['Person']['Sourname'], $Params['Person']['Name'], $Params['Person']['Lastname']); $Query['passport'] = SPrintF('%s %s выдан %s %s', $Params['Person']['PasportLine'], $Params['Person']['PasportNum'], $Params['Person']['PasportWhom'], $Params['Person']['PasportDate']); $Query['residence'] = SPrintF('%s, %s, %s, %s %s', $Params['Person']['pIndex'], $Params['Person']['pState'], $Params['Person']['pCity'], $Params['Person']['pType'], $Params['Person']['pAddress']); $Query['birth_date'] = $Params['Person']['BornDate']; $Query['country'] = isset($Params['Person']['PasportCountry']) ? $Params['Person']['PasportCountry'] : $Params['Person']['pCountry']; $Query['p_addr'] = SPrintF('%s, %s, %s, %s %s, %s', $Params['Person']['pIndex'], $Params['Person']['pState'], $Params['Person']['pCity'], $Params['Person']['pType'], $Params['Person']['pAddress'], $Params['Person']['pRecipient']); $Query['phone'] = $Params['Person']['Phone']; $Query['cell_phone'] = Preg_Replace('/\\s+/', '', $Params['Person']['CellPhone']); $Query['fax'] = $Params['Person']['Fax']; $Query['e_mail'] = $Params['Person']['Email']; #------------------------------------------------------------------------------- break; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- case 'Juridical': #------------------------------------------------------------------------------- $Query['org'] = SPrintF('%s %s', Translit($Params['Person']['CompanyName']), Translit($Params['Person']['CompanyFormFull'])); $Query['org_r'] = SPrintF('%s "%s"', $Params['Person']['CompanyFormFull'], $Params['Person']['CompanyName']); $Query['code'] = $Params['Person']['Inn']; $Query['kpp'] = $Params['Person']['Kpp']; $Query['country'] = $Params['Person']['jCountry']; $Query['address_r'] = SPrintF('%s, %s, %s, %s %s', $Params['Person']['jIndex'], $Params['Person']['pState'], $Params['Person']['jCity'], $Params['Person']['jType'], $Params['Person']['jAddress']); $Query['p_addr'] = SPrintF('%s, %s, %s, %s, %s %s, %s "%s"', $Params['Person']['pIndex'], $Params['Person']['pState'], $Params['Person']['pCountry'], $Params['Person']['pCity'], $Params['Person']['pType'], $Params['Person']['pAddress'], $Params['Person']['CompanyFormFull'], $Params['Person']['CompanyName']); $Query['phone'] = $Params['Person']['Phone']; $Query['cell_phone'] = Preg_Replace('/\\s+/', '', $Params['Person']['CellPhone']); $Query['fax'] = $Params['Person']['Fax']; $Query['e_mail'] = $Params['Person']['Email']; #------------------------------------------------------------------------------- if (In_Array($Params['DomainZone'], array('ru', 'su', 'рф'))) { $Query['ogrn_org'] = $Params['Person']['Ogrn']; } #------------------------------------------------------------------------------- break; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- default: return new gException('WRONG_PROFILE_ID', 'Неверный идентификатор профиля'); } #------------------------------------------------------------------------------- } elseif (In_Array($Params['DomainZone'], array('moscow', 'москва', 'by', 'tatar', 'дети'))) { #------------------------------------------------------------------------------- # Общие поля для организации и физ.лица $Phone = $Params['Person']['Phone']; #------------------------------------------------------------------------------- $Phone = Preg_Split('/\\s+/', $Phone); #------------------------------------------------------------------------------- $Phone = SPrintF('%s.%s%s', Current($Phone), Next($Phone), Next($Phone)); #------------------------------------------------------------------------------- $Query['o_phone'] = $Phone; $Query['addr_lang'] = isset($Params['Person']['jCountry']) ? $Params['Person']['jCountry'] : (isset($Params['Person']['PasportCountry']) ? $Params['Person']['PasportCountry'] : $Params['Person']['pCountry']); $Query['o_email'] = $Params['Person']['Email']; $Query['addr_cc'] = $Query['addr_lang']; $Query['country'] = $Query['addr_lang']; $Query['descr'] = 'Для представительских функций'; #------------------------------------------------------------------------------- switch ($Params['PersonID']) { case 'Natural': #------------------------------------------------------------------------------- $Query['person_r'] = SPrintF('%s %s %s', $Params['Person']['Sourname'], $Params['Person']['Name'], $Params['Person']['Lastname']); $Query['birth_date'] = $Params['Person']['BornDate']; $Query['passport'] = SPrintF('%s %s выдан %s %s', $Params['Person']['PasportLine'], $Params['Person']['PasportNum'], $Params['Person']['PasportWhom'], $Params['Person']['PasportDate']); $Query['addr_street'] = SPrintF('%s %s', $Params['Person']['pType'], $Params['Person']['pAddress']); $Query['addr_city'] = $Params['Person']['pCity']; $Query['addr_sp'] = $Params['Person']['pState']; $Query['addr_pc'] = $Params['Person']['pIndex']; #------------------------------------------------------------------------------- break; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- case 'Juridical': #------------------------------------------------------------------------------- #Контактные данные организации (только при регистрации домена на организацию!) $Query['company_name'] = SPrintF('%s %s', $Params['Person']['CompanyName'], $Params['Person']['CompanyFormFull']); $Query['company_tin'] = $Params['Person']['Inn']; $Query['addr_street'] = SPrintF('%s %s', $Params['Person']['pType'], $Params['Person']['pAddress']); $Query['addr_city'] = $Params['Person']['pCity']; $Query['addr_sp'] = $Params['Person']['pState']; $Query['addr_pc'] = $Params['Person']['pIndex']; #------------------------------------------------------------------------------- $Query['legal_lang'] = 'RU'; $Query['legal_street'] = SPrintF('%s %s', $Params['Person']['jType'], $Params['Person']['jAddress']); $Query['legal_city'] = $Params['Person']['jCity']; $Query['legal_sp'] = $Params['Person']['jState']; $Query['legal_pc'] = $Params['Person']['jIndex']; #------------------------------------------------------------------------------- break; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- default: return new gException('WRONG_PERSON_TYPE_ID_2', 'Неверный идентификатор типа персоны'); } #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- # для .kz - Местонахождение серверного оборудования... Москва, пл. Дзержинского, д. 2 =) $Query['street'] = 'ploschad Dzerzinskogo, dom 2'; $Query['city'] = 'Moscow'; $Query['sp'] = 'Moscow'; #------------------------------------------------------------------------------- switch ($Params['PersonID']) { case 'Natural': #------------------------------------------------------------------------------- $Query['o_company'] = 'Private person'; $Query['a_company'] = 'Private person'; $Query['t_company'] = 'Private person'; $Query['b_company'] = 'Private person'; #------------------------------------------------------------------------------- $Query['o_country_code'] = $Params['Person']['pCountry']; $Query['a_country_code'] = $Params['Person']['pCountry']; $Query['t_country_code'] = $Params['Person']['pCountry']; $Query['b_country_code'] = $Params['Person']['pCountry']; #------------------------------------------------------------------------------- $Query['o_postcode'] = $Params['Person']['pIndex']; $Query['a_postcode'] = $Params['Person']['pIndex']; $Query['t_postcode'] = $Params['Person']['pIndex']; $Query['b_postcode'] = $Params['Person']['pIndex']; #------------------------------------------------------------------------------- $Query['o_first_name'] = Translit($Params['Person']['Name']); $Query['a_first_name'] = Translit($Params['Person']['Name']); $Query['t_first_name'] = Translit($Params['Person']['Name']); $Query['b_first_name'] = Translit($Params['Person']['Name']); #------------------------------------------------------------------------------- $Query['o_last_name'] = Translit($Params['Person']['Sourname']); $Query['a_last_name'] = Translit($Params['Person']['Sourname']); $Query['t_last_name'] = Translit($Params['Person']['Sourname']); $Query['b_last_name'] = Translit($Params['Person']['Sourname']); #------------------------------------------------------------------------------- $Query['o_email'] = $Params['Person']['Email']; $Query['a_email'] = $Params['Person']['Email']; $Query['t_email'] = $Params['Person']['Email']; $Query['b_email'] = $Params['Person']['Email']; #------------------------------------------------------------------------------- $Query['o_addr'] = Translit(SPrintF('%s %s', $Params['Person']['pType'], $Params['Person']['pAddress'])); $Query['a_addr'] = Translit(SPrintF('%s %s', $Params['Person']['pType'], $Params['Person']['pAddress'])); $Query['t_addr'] = Translit(SPrintF('%s %s', $Params['Person']['pType'], $Params['Person']['pAddress'])); $Query['b_addr'] = Translit(SPrintF('%s %s', $Params['Person']['pType'], $Params['Person']['pAddress'])); #------------------------------------------------------------------------------- $Query['o_city'] = Translit($Params['Person']['pCity']); $Query['a_city'] = Translit($Params['Person']['pCity']); $Query['t_city'] = Translit($Params['Person']['pCity']); $Query['b_city'] = Translit($Params['Person']['pCity']); #------------------------------------------------------------------------------- $Query['o_state'] = Translit($Params['Person']['pState']); $Query['a_state'] = Translit($Params['Person']['pState']); $Query['t_state'] = Translit($Params['Person']['pState']); $Query['b_state'] = Translit($Params['Person']['pState']); #------------------------------------------------------------------------------- break; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- case 'Juridical': #------------------------------------------------------------------------------- $Query['o_company'] = SPrintF('%s %s', Translit($Params['Person']['CompanyName']), Translit($Params['Person']['CompanyFormFull'])); $Query['a_company'] = SPrintF('%s %s', Translit($Params['Person']['CompanyName']), Translit($Params['Person']['CompanyFormFull'])); $Query['t_company'] = SPrintF('%s %s', Translit($Params['Person']['CompanyName']), Translit($Params['Person']['CompanyFormFull'])); $Query['b_company'] = SPrintF('%s %s', Translit($Params['Person']['CompanyName']), Translit($Params['Person']['CompanyFormFull'])); #------------------------------------------------------------------------------- $Query['o_country_code'] = $Params['Person']['jCountry']; $Query['a_country_code'] = $Params['Person']['jCountry']; $Query['t_country_code'] = $Params['Person']['jCountry']; $Query['b_country_code'] = $Params['Person']['jCountry']; #------------------------------------------------------------------------------- $Query['o_postcode'] = $Params['Person']['jIndex']; $Query['a_postcode'] = $Params['Person']['jIndex']; $Query['t_postcode'] = $Params['Person']['jIndex']; $Query['b_postcode'] = $Params['Person']['jIndex']; #------------------------------------------------------------------------------- $Query['o_first_name'] = Translit($Params['Person']['dName']); $Query['a_first_name'] = Translit($Params['Person']['dName']); $Query['t_first_name'] = Translit($Params['Person']['dName']); $Query['b_first_name'] = Translit($Params['Person']['dName']); #------------------------------------------------------------------------------- $Query['o_last_name'] = Translit($Params['Person']['dSourname']); $Query['a_last_name'] = Translit($Params['Person']['dSourname']); $Query['t_last_name'] = Translit($Params['Person']['dSourname']); $Query['b_last_name'] = Translit($Params['Person']['dSourname']); #------------------------------------------------------------------------------- $Query['o_email'] = $Params['Person']['Email']; $Query['a_email'] = $Params['Person']['Email']; $Query['t_email'] = $Params['Person']['Email']; $Query['b_email'] = $Params['Person']['Email']; #------------------------------------------------------------------------------- $Query['o_addr'] = Translit(SPrintF('%s %s', $Params['Person']['jType'], $Params['Person']['jAddress'])); $Query['a_addr'] = Translit(SPrintF('%s %s', $Params['Person']['jType'], $Params['Person']['jAddress'])); $Query['t_addr'] = Translit(SPrintF('%s %s', $Params['Person']['jType'], $Params['Person']['jAddress'])); $Query['b_addr'] = Translit(SPrintF('%s %s', $Params['Person']['jType'], $Params['Person']['jAddress'])); #------------------------------------------------------------------------------- $Query['o_city'] = Translit($Params['Person']['jCity']); $Query['a_city'] = Translit($Params['Person']['jCity']); $Query['t_city'] = Translit($Params['Person']['jCity']); $Query['b_city'] = Translit($Params['Person']['jCity']); #------------------------------------------------------------------------------- $Query['o_state'] = Translit($Params['Person']['jState']); $Query['a_state'] = Translit($Params['Person']['jState']); $Query['t_state'] = Translit($Params['Person']['jState']); $Query['b_state'] = Translit($Params['Person']['jState']); #------------------------------------------------------------------------------- break; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- default: return new gException('WRONG_PERSON_TYPE_ID', 'Неверный идентификатор типа персоны'); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $Phone = $Params['Person']['Phone']; #------------------------------------------------------------------------------- if ($Phone) { #------------------------------------------------------------------------------- $Phone = Preg_Split('/\\s+/', $Phone); #------------------------------------------------------------------------------- $Phone = SPrintF('%s.%s%s', Current($Phone), Next($Phone), Next($Phone)); #------------------------------------------------------------------------------- $Query['o_phone'] = $Phone; $Query['a_phone'] = $Phone; $Query['t_phone'] = $Phone; $Query['b_phone'] = $Phone; #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- $Query['o_phone'] = ''; $Query['a_phone'] = ''; $Query['t_phone'] = ''; $Query['b_phone'] = ''; #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $Fax = $Params['Person']['Fax']; #------------------------------------------------------------------------------- if ($Fax) { #------------------------------------------------------------------------------- $Fax = Preg_Split('/\\s+/', $Fax); #------------------------------------------------------------------------------- $Fax = SPrintF('%s.%s%s', Current($Fax), Next($Fax), Next($Fax)); #------------------------------------------------------------------------------- $Query['o_fax'] = $Fax; $Query['a_fax'] = $Fax; $Query['t_fax'] = $Fax; $Query['b_fax'] = $Fax; #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- $Query['o_fax'] = ''; $Query['a_fax'] = ''; $Query['t_fax'] = ''; $Query['b_fax'] = ''; #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $Query['ns0'] = $Params['Ns1Name']; $Query['ns1'] = $Params['Ns2Name']; #------------------------------------------------------------------------------- if ($Params['Ns3Name']) { $Query['ns3'] = $Params['Ns3Name']; } #------------------------------------------------------------------------------- if ($Params['Ns4Name']) { $Query['ns4'] = $Params['Ns4Name']; } #------------------------------------------------------------------------------- if ($Params['Ns1IP'] && $Params['Ns2IP']) { #------------------------------------------------------------------------------- $Query['ns0ip'] = $Params['Ns1IP']; $Query['ns1ip'] = $Params['Ns2IP']; } #------------------------------------------------------------------------------- if ($Params['Ns3IP']) { $Query['ns3ip'] = $Params['Ns3IP']; } #------------------------------------------------------------------------------- if ($Params['Ns4IP']) { $Query['ns4ip'] = $Params['Ns4IP']; } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- if ($Params['DomainZone'] == 'aero') { $Query['aerodata'] = SPrintF('%s.%s', $Params['DomainName'], $Params['DomainZone']); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- return $Query; #------------------------------------------------------------------------------- }