/** * <p>Подготавливает день рождения для вывода.</p> * * * @param date $datetime Дата рождения * * @param char $gender Пол. Допустимые значения: M - мужской, F - женский, X - средний. * * @param char $showYear = "N" Показывать ли год рождения. Допустимые значения: Y - показывать, M - * показывать только для мужского пола, N - не показывать. * * @return array <p>Метод возвращает массив с ключами: DATE - отформатированный день * рождения, MONTH - месяц рождения, DAY - день в месяце.</p> <br><br> * * @static * @link http://dev.1c-bitrix.ru/api_help/socialnetwork/classes/csocnettools/csocnettools_birthday.php * @author Bitrix */ public static function Birthday($datetime, $gender, $showYear = "N") { if (StrLen($datetime) <= 0) { return false; } $arDateTmp = ParseDateTime($datetime, CSite::GetDateFormat('SHORT')); $day = IntVal($arDateTmp["DD"]); $month = IntVal($arDateTmp["MM"]); $year = IntVal($arDateTmp["YYYY"]); $val = $day . ' ' . ToLower(GetMessage('MONTH_' . $month . '_S')); if ($showYear == 'Y' || $showYear == 'M' && $gender == 'M') { $val .= ' ' . $year; } return array("DATE" => $val, "MONTH" => Str_Pad(IntVal($arDateTmp["MM"]), 2, "0", STR_PAD_LEFT), "DAY" => Str_Pad(IntVal($arDateTmp["DD"]), 2, "0", STR_PAD_LEFT)); }
#------------------------------------------------------------------------------- $key[$i] = $key[$i] ^ $salt[$i - 8]; #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- # create message $n = 8 - StrLen($Result) % 8; #------------------------------------------------------------------------------- $pad = Str_Pad($Result, StrLen($Result) + $n, ' '); #------------------------------------------------------------------------------- # crypt message $crypted = mcrypt_encrypt(MCRYPT_3DES, $key, $pad, MCRYPT_MODE_ECB, ""); #------------------------------------------------------------------------------- $Result = "qiwi" . Str_Pad($Settings['Send']['from'], 10, "0", STR_PAD_LEFT) . "\n"; #------------------------------------------------------------------------------- $Result .= base64_encode($crypted); #------------------------------------------------------------------------------- # send message to QIWI server $HTTP = array('Protocol' => $Settings['Send']['UseSSL'] ? 'ssl' : 'tcp', 'Port' => $Settings['Send']['UseSSL'] ? '443' : '80', 'Address' => 'ishop.qiwi.ru', 'Host' => 'ishop.qiwi.ru', 'IsLogging' => $Settings['IsLogging']); #------------------------------------------------------------------------------- $Send = HTTP_Send('/xml', $HTTP, array(), $Result, array('Content-type: text/xml; encoding=utf-8')); #------------------------------------------------------------------------------- if (Is_Error($Send)) { return TRUE; } #------------------------------------------------------------------------------- # parse XML if (Mb_StrLen($Send['Body']) == 0) { #-------------------------------------------------------------------------------
function Birthday($datetime, $gender, $showYear = "N") { if (StrLen($datetime) <= 0) { return false; } $arDateTmp = ParseDateTime($datetime, CSite::GetDateFormat('SHORT')); $day = IntVal($arDateTmp["DD"]); if (isset($arDateTmp["M"])) { if (is_numeric($arDateTmp["M"])) { $month = IntVal($arDateTmp["M"]); } else { $month = GetNumMonth($arDateTmp["M"], true); if (!$month) { $month = intval(date('m', strtotime($arDateTmp["M"]))); } } } elseif (isset($arDateTmp["MMMM"])) { if (is_numeric($arDateTmp["MMMM"])) { $month = intval($arDateTmp["MMMM"]); } else { $month = GetNumMonth($arDateTmp["MMMM"]); if (!$month) { $month = intval(date('m', strtotime($arDateTmp["MMMM"]))); } } } else { $month = IntVal($arDateTmp["MM"]); } $arDateTmp["MM"] = $month; $year = IntVal($arDateTmp["YYYY"]); if ($showYear == 'Y' || $showYear == 'M' && $gender == 'M') { $date_template = GetMessage("SONET_BIRTHDAY_DAY_TEMPLATE"); } else { $date_template = GetMessage("SONET_BIRTHDAY_DAY_TEMPLATE_WO_YEAR"); } $val = str_replace(array("#DAY#", "#MONTH#", "#MONTH_LOW#", "#YEAR#"), array($day, GetMessage("MONTH_" . $month . "_S"), ToLower(GetMessage("MONTH_" . $month . "_S")), $year), $date_template); return array("DATE" => $val, "MONTH" => Str_Pad(IntVal($arDateTmp["MM"]), 2, "0", STR_PAD_LEFT), "DAY" => Str_Pad(IntVal($arDateTmp["DD"]), 2, "0", STR_PAD_LEFT)); }
function To_XML_String($Value, $Name = 'XML', $Level = 0) { /******************************************************************************/ $__args_types = array('array,string,integer,double,boolean,NULL', 'string,integer', 'integer'); #------------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /******************************************************************************/ $Result = SPrintF('%s<%s', $Tab = $Level ? Str_Pad("\t", $Level, "\t") : '', $Name); #------------------------------------------------------------------------------- if (Is_Array($Value)) { #------------------------------------------------------------------------------- if (Count($Value) > 0) { #------------------------------------------------------------------------------- $Result = SPrintF("%s>\n", $Result); #------------------------------------------------------------------------------- foreach (Array_Keys($Value) as $Key) { $Result = SPrintF('%s%s', $Result, To_XML_String($Value[$Key], $Key, $Level + 1)); } #------------------------------------------------------------------------------- $Result = SPrintF('%s%s', $Result, $Tab); #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- return SPrintF("%s type=\"array\" />\n", $Result); #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- $Type = GetType($Value); #------------------------------------------------------------------------------- if ($Type != 'string') { $Result = SPrintF('%s type="%s"', $Result, $Type); } #------------------------------------------------------------------------------- if (StrLen($Value) > 0) { #------------------------------------------------------------------------------- $Value = HtmlSpecialChars((string) $Value); #------------------------------------------------------------------------------- $Result = SPrintF('%s>%s', $Result, $Value); #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- return SPrintF("%s />\n", $Result); #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- return SPrintF("%s</%s>\n", $Result, $Name); #------------------------------------------------------------------------------- }
function ToXMLString($Level = 0, $IsFormat = TRUE) { /****************************************************************************/ $__args_types = array('integer', 'boolean'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Name = $this->Name; #----------------------------------------------------------------------------- $Result = SPrintF('<%s', $Name); #----------------------------------------------------------------------------- if ($IsFormat) { $Result = SPrintF('%s%s', $Level ? Str_Pad(' ', $Level) : '', $Result); } #----------------------------------------------------------------------------- $Attribs = $this->Attribs; #----------------------------------------------------------------------------- foreach (Array_Keys($Attribs) as $AttribID) { $Result .= SPrintF(' %s="%s"', $AttribID, HtmlSpecialChars((string) $Attribs[$AttribID])); } #----------------------------------------------------------------------------- $Childs = $this->Childs; #----------------------------------------------------------------------------- if (Count($Childs)) { #--------------------------------------------------------------------------- $Result .= '>'; #--------------------------------------------------------------------------- $IsNoCData = TRUE; #--------------------------------------------------------------------------- foreach ($Childs as $Child) { #------------------------------------------------------------------------- if (In_Array($Child->Name, array('CDATA'))) { #----------------------------------------------------------------------- $IsNoCData = FALSE; #----------------------------------------------------------------------- break; } } #--------------------------------------------------------------------------- $Nodes = ''; #--------------------------------------------------------------------------- foreach ($Childs as $Child) { $Nodes .= In_Array($Child->Name, array('CDATA')) ? HtmlSpecialChars($Child->Text) : $Child->ToXMLString($Level + 1, $IsNoCData); } #--------------------------------------------------------------------------- $Result .= $IsNoCData ? SPrintF("\n%s%s", $Nodes, $Level ? Str_Pad(' ', $Level) : '') : $Nodes; } else { #--------------------------------------------------------------------------- $Text = isset($Attribs['force-escape']) ? $this->Text : HtmlSpecialChars($this->Text); #--------------------------------------------------------------------------- $IsShort = !Mb_StrLen($Text) && !In_Array($Name, array('TEXTAREA', 'BUTTON', 'TITLE', 'SCRIPT', 'TABLE', 'TD', 'TR')); #--------------------------------------------------------------------------- if ($IsShort) { #------------------------------------------------------------------------- $Result .= ' />'; #------------------------------------------------------------------------- if ($IsFormat) { $Result .= "\n"; } #------------------------------------------------------------------------- return $Result; } else { $Result .= SPrintF('>%s', $Text); } } #----------------------------------------------------------------------------- $Result .= SPrintF('</%s>', $Name); #----------------------------------------------------------------------------- if ($IsFormat) { $Result .= "\n"; } #----------------------------------------------------------------------------- return $Result; }