function Sources(&$Object) { #----------------------------------------------------------------------------- $Attribs =& $Object->Attribs; #----------------------------------------------------------------------------- foreach (array('src', 'style', 'href', 'onclick') as $AttribID) { #--------------------------------------------------------------------------- if (!isset($Attribs[$AttribID])) { continue; } #--------------------------------------------------------------------------- $Attrib =& $Attribs[$AttribID]; #--------------------------------------------------------------------------- if (Preg_Match_All('/SRC\\:\\{([a-zA-Z0-9\\.\\/\\_\\-]+)[?a-zA-Z\\=\\,]*\\}/', $Attrib, $Matches)) { #------------------------------------------------------------------------- $Matches = Array_Combine(Current($Matches), Next($Matches)); #------------------------------------------------------------------------- foreach (Array_Keys($Matches) as $What) { #----------------------------------------------------------------------- $Url = Styles_Url($Matches[$What]); if (!Is_Error($Url)) { $Attrib = Str_Replace($What, $Url, $Attrib); } } } } }
#----------------------------------------------------------------------------- # Все цвета в стиле $Finded = array(); #----------------------------------------------------------------------------- foreach ($Files as $File) { #--------------------------------------------------------------------------- if (Preg_Match('/\\/others\\//', $File)) { continue; } #--------------------------------------------------------------------------- $Sourse = IO_Read($File); if (Is_Error($Sourse)) { return ERROR | @Trigger_Error(500); } #--------------------------------------------------------------------------- if (Preg_Match_All('/#[a-zA-F0-9]{6}/', $Sourse, $Matches) > 1) { #------------------------------------------------------------------------- foreach (Current($Matches) as $Match) { $Finded[Md5($Match)] = Mb_SubStr($Match, 1); } } } #----------------------------------------------------------------------------- if (Count($Finded) < 1) { continue; } #----------------------------------------------------------------------------- $Tr = new Tag('TR'); #----------------------------------------------------------------------------- foreach ($Finded as $Color) { #---------------------------------------------------------------------------
function RuCenter_Check_Task($Settings, $TicketID) { /****************************************************************************/ $__args_types = array('array', 'string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $HTTP = array('Address' => $Settings['Address'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Charset' => 'KOI8-R', 'IsLogging' => $Settings['Params']['IsLogging']); #----------------------------------------------------------------------------- $Query = array(); #----------------------------------------------------------------------------- $RequestID = UniqID('ID'); #----------------------------------------------------------------------------- $Query[] = 'lang: ru'; $Query[] = SPrintF('login: %s', $Settings['Login']); $Query[] = SPrintF('password: %s', $Settings['Password']); $Query[] = 'request: order'; $Query[] = 'operation: get'; $Query[] = SPrintF('request-id: %s', $RequestID); #----------------------------------------------------------------------------- $Query[] = ''; #----------------------------------------------------------------------------- $Query[] = '[order]'; $Query[] = SPrintF('order_id: %s', $TicketID); #----------------------------------------------------------------------------- $Result = HTTP_Send('/dns/dealer', $HTTP, array(), array('SimpleRequest' => Implode("\n", $Query))); if (Is_Error($Result)) { return ERROR | @Trigger_Error('[RuCenter_Check_Task]: не удалось выполнить запрос к серверу'); } #----------------------------------------------------------------------------- if (Preg_Match('/HTTP\\/1.0\\s502/i', $Result['Heads'])) { return false; } #----------------------------------------------------------------------------- $Result = Trim($Result['Body']); #----------------------------------------------------------------------------- if (Preg_Match('/State:\\s([0-9]+)\\s/', $Result, $CodeID)) { #--------------------------------------------------------------------------- $CodeID = Next($CodeID); #--------------------------------------------------------------------------- switch ($CodeID) { case '200': #----------------------------------------------------------------------- if (Preg_Match_All('/state:(waiting|failed|running|completed|deleted)/', $Result, $Matches)) { #--------------------------------------------------------------------- $Matches = Next($Matches); #--------------------------------------------------------------------- switch (End($Matches)) { case 'waiting': return FALSE; case 'running': return FALSE; case 'completed': return array('DomainID' => 0); case 'failed': return new gException('OPERATION_FAILED', 'Произошла ошибка'); case 'deleted': return new gException('ORDER_DELETED', 'Заказ отозван клиентом (партнером)'); default: return new gException('WRONG_ERROR', 'Неизвестный статус заказа'); } } break; case '500': return FALSE; default: return new gException('WRONG_ERROR', SPrintF('Неизвестный статус ошибки (%s)', $Result)); } } #----------------------------------------------------------------------------- return new gException('WRONG_ANSWER', $Result); }
function String_Xml_Parse($String, $IsUseCache = TRUE) { #------------------------------------------------------------------------------- # костыль для удаления не-UTF8 символов $String = iconv('UTF-8', 'UTF-8//IGNORE', $String); #------------------------------------------------------------------------------- $Length = Mb_StrLen($String); #------------------------------------------------------------------------------- $IsUseCache = $IsUseCache && $Length > 1024; #------------------------------------------------------------------------------- if ($IsUseCache) { #------------------------------------------------------------------------------- $CacheID = SPrintF('String_XML_Parse[%s]', Md5(Crc32($String))); #------------------------------------------------------------------------------- $Result = CacheManager::get($CacheID); if ($Result) { return $Result; } } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- Debug(SPrintF('[String_XML_Parse]: парсирование строки (%u bytes)', $Length)); #------------------------------------------------------------------------------- $XmlParser = Xml_Parser_Create('UTF-8'); #------------------------------------------------------------------------------- if (!Xml_Parser_Set_Option($XmlParser, XML_OPTION_CASE_FOLDING, FALSE)) { return ERROR | Trigger_Error('[String_Xml_Parse]: не удалось установить опцию парсирования (XML_OPTION_CASE_FOLDING)'); } #------------------------------------------------------------------------------- if (!Xml_Parser_Set_Option($XmlParser, XML_OPTION_SKIP_WHITE, FALSE)) { return ERROR | Trigger_Error('[String_Xml_Parse]: не удалось установить опцию парсирования (XML_OPTION_SKIP_WHITE)'); } #------------------------------------------------------------------------------- if (!Xml_Parse_Into_Struct($XmlParser, $String, $Nodes)) { #------------------------------------------------------------------------------- $ByteIndex = Xml_Get_Current_Byte_Index($XmlParser); #------------------------------------------------------------------------------- Debug(SPrintF('[system/libs/auto/String.php]: xml_error_string = %s', Xml_Error_String(Xml_Get_Error_Code($XmlParser)))); #------------------------------------------------------------------------------- Debug(SPrintF('[system/libs/auto/String.php]: %s', Mb_SubStr($String, $ByteIndex - 100, $ByteIndex + 100))); #------------------------------------------------------------------------------- $Buffer = Mb_SubStr($String, 0, $ByteIndex); #------------------------------------------------------------------------------- $Line = Preg_Match_All("/(\r\n|\n)/sU", $Buffer, $Matches) + 1; #------------------------------------------------------------------------------- return new gException('XML_PARSE_ERROR', SPrintF('%s в линии %u', Xml_Error_String($XmlParser), $Line)); #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- #----------------------------------------------------------------------------- Xml_Parser_Free($XmlParser); #----------------------------------------------------------------------------- $Root = new Tag('__ROOT__'); #----------------------------------------------------------------------------- $Links = array(&$Root); #----------------------------------------------------------------------------- foreach ($Nodes as $Node) { #--------------------------------------------------------------------------- $Current = $Links[Count($Links) - 1]; #--------------------------------------------------------------------------- switch ($Node['type']) { case 'open': #----------------------------------------------------------------------- $Tag = new Tag($Node['tag']); #----------------------------------------------------------------------- if (isset($Node['attributes'])) { $Tag->AddAttribs($Node['attributes']); } #----------------------------------------------------------------------- if (isset($Node['value'])) { #--------------------------------------------------------------------- $Value = $Node['value']; #--------------------------------------------------------------------- if (Trim($Value)) { $Tag->AddChild(new Tag('CDATA', $Value)); } } #----------------------------------------------------------------------- $Current->Childs[] = $Tag; #----------------------------------------------------------------------- $Links[] =& $Current->Childs[Count($Current->Childs) - 1]; break; case 'cdata': #----------------------------------------------------------------------- $Value = $Node['value']; #----------------------------------------------------------------------- if (Trim($Value)) { #--------------------------------------------------------------------- $Tag = new Tag('CDATA', $Value); #--------------------------------------------------------------------- $Current->Childs[] = $Tag; } break; case 'complete': #----------------------------------------------------------------------- $Tag = new Tag($Node['tag']); #----------------------------------------------------------------------- if (isset($Node['attributes'])) { $Tag->AddAttribs($Node['attributes']); } #----------------------------------------------------------------------- if (isset($Node['value'])) { $Tag->AddText($Node['value']); } #----------------------------------------------------------------------- $Current->Childs[] = $Tag; break; case 'close': Array_Pop($Links); break; default: # No more... } } #----------------------------------------------------------------------------- if ($IsUseCache) { CacheManager::add($CacheID, $Root); } #----------------------------------------------------------------------------- return $Root; }
if (Is_Error($Comp)) { return ERROR | @Trigger_Error(500); } #--------------------------------------------------------------------------- return $Comp; case 'array': #--------------------------------------------------------------------------- $Ul = new Tag('UL', array('class' => 'Standard')); #--------------------------------------------------------------------------- foreach ($Clauses as $Clause) { #------------------------------------------------------------------------- $Li = new Tag('LI', array('style' => 'border-bottom:1px dashed #DCDCDC;'), new Tag('A', array('href' => SPrintF('/Clause?ClauseID=%s', $Clause['Partition'])), $Clause['Title'])); #------------------------------------------------------------------------- $Text = ''; #------------------------------------------------------------------------- if (Preg_Match_All('/<\\s*[P|TD|DIV].*>(.+)<\\s*\\/[P|TD|DIV].*>/siU', $Clause['Text'], $Matches)) { #----------------------------------------------------------------------- $Matches = Next($Matches); #----------------------------------------------------------------------- for ($i = 0; $i < Count($Matches); $i++) { $Text .= SPrintF('%s ', $Matches[$i]); } } #------------------------------------------------------------------------- $Text = Mb_SubStr(Html_Entity_Decode(Strip_Tags(Trim($Text))), 0, 200); #------------------------------------------------------------------------- if ($Text) { #----------------------------------------------------------------------- $Div = new Tag('DIV', array('style' => 'color:#848484;'), SPrintF('%s...', $Text)); #----------------------------------------------------------------------- $Li->AddChild($Div);
} #----------------------------------------------------------------------------- $Source = IO_Read($File); if (Is_Error($Source)) { return ERROR | @Trigger_Error(500); } #----------------------------------------------------------------------------- if (Preg_Match_All('/\\/\\*\\*\\n.+\\*\\//sU', $Source, $Matches)) { #--------------------------------------------------------------------------- $FilesList[] = $File; #--------------------------------------------------------------------------- echo SPrintF("Читаем файл %s\n", $File); #--------------------------------------------------------------------------- $Docs = Current($Matches); #--------------------------------------------------------------------------- if (Preg_Match_All('/(public|private|)+\\sfunction\\s([a-zA-Z\\_]+)\\(([\\$a-zA-Z0-9\\_\\=\\s\\,\\&\\(\\)\']*)\\){.*/siU', $Source, $Matches)) { #------------------------------------------------------------------------- $Polimoths = Next($Matches); $Functions = Next($Matches); $Arguments = Next($Matches); #------------------------------------------------------------------------- echo SPrintF("Кол-во описаний %u\nКол-во функций %u\n", Count($Functions), Count($Docs)); #------------------------------------------------------------------------- $DOM = new DOM(); #------------------------------------------------------------------------- if (Is_Error($DOM->Load('JBsDoc'))) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------- if (Preg_Match('/(.*)(.class|.php)$/', BaseName($File), $String)) { $DOM->AddText('Title', Next($String));
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; #------------------------------------------------------------------------------- }
function VarCont($text) { if (!strpos($text, '##')) { return $text; } Preg_Match_All("~##([^#]+)##~", $text, $m); if (!$m[1]) { return $text; } #Mini-Template foreach (end($m) as $var) { $v2 = str_replace('$', '', $var); #if($GLOBALS[$v2]) $text = str_replace('##' . $var . '##', $GLOBALS[$v2], $text); } return $text; }