Ejemplo n.º 1
0
	public static function DoValidate($arParams, $arQuestion, $arAnswers, $arValues)
	{
		global $APPLICATION;
		
		foreach ($arValues as $value)
		{
			if (strlen($value) <= 0) continue;
			
			// prepare check numbers
			$arValueCheck = ParseDateTime($value);
			$valueCheckSum = $arValueCheck["YYYY"] + $arValueCheck["MM"]/12 + $arValueCheck["DD"]/365;
			$currentCheckSum = date("Y") + date("n")/12 + date("j")/365;

			// check minimum age
			if (strlen($arParams["AGE_TO"]) > 0 && $valueCheckSum < $currentCheckSum-$arParams["AGE_TO"])
			{
				$APPLICATION->ThrowException(GetMessage("FORM_VALIDATOR_VAL_DATE_AGE_ERROR_MORE"));
				return false;
			}
			
			// check minimum age
			if (strlen($arParams["AGE_FROM"]) > 0 && $valueCheckSum > $currentCheckSum-$arParams["AGE_FROM"])
			{
				$APPLICATION->ThrowException(GetMessage("FORM_VALIDATOR_VAL_DATE_AGE_ERROR_LESS"));
				return false;
			}
		}
		
		return true;
	}
Ejemplo n.º 2
0
 public static function IsMaxDatabaseDate($datetime, $format = false)
 {
     $parts = ParseDateTime($datetime, is_string($format) && $format !== '' ? $format : FORMAT_DATETIME);
     if (!is_array($parts)) {
         return false;
     }
     $year = isset($parts['YYYY']) ? intval($parts['YYYY']) : 0;
     return $year === 9999;
 }
 /**
  * Генерирует HTML для поля в списке
  * @see AdminListHelper::addRowCell();
  * @param CAdminListRow $row
  * @param array $data - данные текущей строки
  * @return mixed
  */
 public function generateRow(&$row, $data)
 {
     if (isset($this->settings['EDIT_IN_LIST']) and $this->settings['EDIT_IN_LIST']) {
         $row->AddCalendarField($this->getCode());
     } else {
         $arDate = ParseDateTime($this->getValue());
         if ($arDate['YYYY'] < 10) {
             $stDate = '-';
         } else {
             $stDate = ConvertDateTime($this->getValue(), "DD.MM.YYYY HH:MI:SS", "ru");
         }
         $row->AddViewField($this->getCode(), $stDate);
     }
 }
Ejemplo n.º 4
0
 function IsToday($date)
 {
     if ($date && ($arDate = ParseDateTime($date, CSite::GetDateFormat('SHORT')))) {
         if (isset($arDate["M"])) {
             if (is_numeric($arDate["M"])) {
                 $arDate["MM"] = intval($arDate["M"]);
             } else {
                 $arDate["MM"] = GetNumMonth($arDate["M"], true);
                 if (!$arDate["MM"]) {
                     $arDate["MM"] = intval(date('m', strtotime($arDate["M"])));
                 }
             }
         } elseif (isset($arDate["MMMM"])) {
             if (is_numeric($arDate["MMMM"])) {
                 $arDate["MM"] = intval($arDate["MMMM"]);
             } else {
                 $arDate["MM"] = GetNumMonth($arDate["MMMM"]);
                 if (!$arDate["MM"]) {
                     $arDate["MM"] = intval(date('m', strtotime($arDate["MMMM"])));
                 }
             }
         }
         return intval($arDate['MM']) == date('n') && intval($arDate['DD']) == date('j');
     } else {
         return false;
     }
 }
Ejemplo n.º 5
0
 function GetList($arOrder = array("ID" => "DESC"), $arFilter = array())
 {
     global $DB;
     $err_mess = "FILE: " . __FILE__ . "<br>LINE: ";
     $arSqlSearch = array();
     $arSqlOrder = array();
     $arOFields = array("ID" => "A.ID", "ACTIVE" => "A.ACTIVE", "IS_PERIOD" => "A.IS_PERIOD", "NAME" => "A.NAME", "MODULE_ID" => "A.MODULE_ID", "USER_ID" => "A.USER_ID", "LAST_EXEC" => "A.LAST_EXEC", "AGENT_INTERVAL" => "A.AGENT_INTERVAL", "NEXT_EXEC" => "A.NEXT_EXEC", "SORT" => "A.SORT");
     if (!is_array($arFilter)) {
         $filter_keys = array();
     } else {
         $filter_keys = array_keys($arFilter);
     }
     for ($i = 0, $n = count($filter_keys); $i < $n; $i++) {
         $val = $arFilter[$filter_keys[$i]];
         $key = strtoupper($filter_keys[$i]);
         if (strlen($val) <= 0 || $key == "USER_ID" && $val !== false && $val !== null) {
             continue;
         }
         switch ($key) {
             case "ID":
                 $arSqlSearch[] = "A.ID=" . IntVal($val);
                 break;
             case "ACTIVE":
                 $t_val = strtoupper($val);
                 if ($t_val == "Y" || $t_val == "N") {
                     $arSqlSearch[] = "A.ACTIVE='" . $t_val . "'";
                 }
                 break;
             case "IS_PERIOD":
                 $t_val = strtoupper($val);
                 if ($t_val == "Y" || $t_val == "N") {
                     $arSqlSearch[] = "A.IS_PERIOD='" . $t_val . "'";
                 }
                 break;
             case "NAME":
                 $arSqlSearch[] = "A.NAME LIKE '" . $DB->ForSQLLike($val) . "'";
                 break;
             case "MODULE_ID":
                 $arSqlSearch[] = "A.MODULE_ID = '" . $DB->ForSQL($val) . "'";
                 break;
             case "USER_ID":
                 $arSqlSearch[] = "A.USER_ID " . (IntVal($val) <= 0 ? "IS NULL" : "=" . IntVal($val));
                 break;
             case "LAST_EXEC":
                 $arr = ParseDateTime($val, CLang::GetDateFormat());
                 if ($arr) {
                     $date2 = mktime(0, 0, 0, $arr["MM"], $arr["DD"] + 1, $arr["YYYY"]);
                     $arSqlSearch[] = "A.LAST_EXEC>=" . $DB->CharToDateFunction($DB->ForSql($val), "SHORT") . " AND A.LAST_EXEC<" . $DB->CharToDateFunction(ConvertTimeStamp($date2), "SHORT");
                 }
                 break;
             case "NEXT_EXEC":
                 $arr = ParseDateTime($val);
                 if ($arr) {
                     $date2 = mktime(0, 0, 0, $arr["MM"], $arr["DD"] + 1, $arr["YYYY"]);
                     $arSqlSearch[] = "A.NEXT_EXEC>=" . $DB->CharToDateFunction($DB->ForSql($val), "SHORT") . " AND A.NEXT_EXEC<" . $DB->CharToDateFunction(ConvertTimeStamp($date2), "SHORT");
                 }
                 break;
         }
     }
     foreach ($arOrder as $by => $order) {
         $by = strtoupper($by);
         $order = strtoupper($order);
         if (array_key_exists($by, $arOFields)) {
             if ($order != "ASC") {
                 $order = "DESC" . ($DB->type == "ORACLE" ? " NULLS LAST" : "");
             } else {
                 $order = "ASC" . ($DB->type == "ORACLE" ? " NULLS FIRST" : "");
             }
             $arSqlOrder[] = $arOFields[$by] . " " . $order;
         }
     }
     $strSql = "SELECT A.ID, A.MODULE_ID, A.USER_ID, B.LOGIN, B.NAME as USER_NAME, B.LAST_NAME, A.SORT, " . "A.NAME, A.ACTIVE, " . $DB->DateToCharFunction("A.LAST_EXEC") . " as LAST_EXEC, " . $DB->DateToCharFunction("A.NEXT_EXEC") . " as NEXT_EXEC, " . "A.AGENT_INTERVAL, A.IS_PERIOD " . "FROM b_agent A LEFT JOIN b_user B ON(A.USER_ID = B.ID)";
     $strSql .= count($arSqlSearch) > 0 ? " WHERE " . implode(" AND ", $arSqlSearch) : "";
     $strSql .= count($arSqlOrder) > 0 ? " ORDER BY " . implode(", ", $arSqlOrder) : "";
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     return $res;
 }
Ejemplo n.º 6
0
	public static function BuildRSS($postID, $blogID, $type = "RSS2.0", $numPosts = 10, $arPathTemplate = Array())
	{
		$blogID = IntVal($blogID);
		$postID = IntVal($postID);
		if($blogID <= 0)
			return false;
		if($postID <= 0)
			return false;
		$numPosts = IntVal($numPosts);
		$type = strtolower(preg_replace("/[^a-zA-Z0-9.]/is", "", $type));
		if ($type != "rss.92" && $type != "atom.03")
			$type = "rss2.0";

		$rssText = False;

		$arBlog = CBlog::GetByID($blogID);
		if ($arBlog && $arBlog["ACTIVE"] == "Y" && $arBlog["ENABLE_RSS"] == "Y")
		{
			$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
			if($arGroup["SITE_ID"] == SITE_ID)
			{
				$arPost = CBlogPost::GetByID($postID);
				if(!empty($arPost) && $arPost["BLOG_ID"] == $arBlog["ID"] && $arPost["ENABLE_COMMENTS"] == "Y")
				{
					$now = date("r");
					$nowISO = date("Y-m-d\TH:i:s").substr(date("O"), 0, 3).":".substr(date("O"), -2, 2);

					$serverName = "";
					$charset = "";
					$language = "";
					$dbSite = CSite::GetList(($b = "sort"), ($o = "asc"), array("LID" => SITE_ID));
					if ($arSite = $dbSite->Fetch())
					{
						$serverName = $arSite["SERVER_NAME"];
						$charset = $arSite["CHARSET"];
						$language = $arSite["LANGUAGE_ID"];
					}

					if (strlen($serverName) <= 0)
					{
						if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0)
							$serverName = SITE_SERVER_NAME;
						else
							$serverName = COption::GetOptionString("main", "server_name", "");
					}

					if (strlen($charset) <= 0)
					{
						if (defined("SITE_CHARSET") && strlen(SITE_CHARSET) > 0)
							$charset = SITE_CHARSET;
						else
							$charset = "windows-1251";
					}

					if(strlen($arPathTemplate["PATH_TO_BLOG"])>0)
						$blogURL = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_BLOG"], array("blog" => $arBlog["URL"], "user_id" => $arBlog["OWNER_ID"], "group_id" => $arBlog["SOCNET_GROUP_ID"])));
					else
						$blogURL = htmlspecialcharsbx("http://".$serverName.CBlog::PreparePath($arBlog["URL"], $arGroup["SITE_ID"]));

					if(strlen($arPathTemplate["PATH_TO_POST"])>0)
						$url = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_POST"], array("blog" => $arBlog["URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arPathTemplate["ALLOW_POST_CODE"]), "user_id" => $arBlog["OWNER_ID"], "group_id" => $arBlog["SOCNET_GROUP_ID"])));
					else
						$url = htmlspecialcharsbx("http://".$serverName.CBlogPost::PreparePath($arBlog["URL"], $arPost["ID"], $arGroup["SITE_ID"]));

					$dbUser = CUser::GetByID($arPost["AUTHOR_ID"]);
					$arUser = $dbUser->Fetch();

					if($arPathTemplate["USE_SOCNET"] == "Y")
					{
						$blogName = GetMessage("BLG_GCM_RSS_TITLE_SOCNET", Array("#AUTHOR_NAME#" => htmlspecialcharsEx($arUser["NAME"]." ".$arUser["LAST_NAME"]), "#POST_TITLE#" => htmlspecialcharsEx($arPost["TITLE"])));
					}
					else
					{
						$blogName = GetMessage("BLG_GCM_RSS_TITLE", Array("#BLOG_NAME#" => htmlspecialcharsEx($arBlog["NAME"]), "#POST_TITLE#" => htmlspecialcharsEx($arPost["TITLE"])));
					}

					$rssText = "";
					if ($type == "rss.92")
					{
						$rssText .= "<"."?xml version=\"1.0\" encoding=\"".$charset."\"?".">\n\n";
						$rssText .= "<rss version=\".92\">\n";
						$rssText .= " <channel>\n";
						$rssText .= "	<title>".$blogName."</title>\n";
						$rssText .= "	<description>".$blogName."</description>\n";
						$rssText .= "	<link>".$url."</link>\n";
						$rssText .= "	<language>".$language."</language>\n";
						$rssText .= "	<docs>http://backend.userland.com/rss092</docs>\n";
						$rssText .= "\n";
					}
					elseif ($type == "rss2.0")
					{
						$rssText .= "<"."?xml version=\"1.0\" encoding=\"".$charset."\"?".">\n\n";
						$rssText .= "<rss version=\"2.0\">\n";
						$rssText .= " <channel>\n";
						$rssText .= "	<title>".$blogName."</title>\n";
						$rssText .= "	<description>".$blogName."</description>\n";
						//$rssText .= "	<guid>".$url."</guid>\n";
						$rssText .= "	<link>".$url."</link>\n";
						$rssText .= "	<language>".$language."</language>\n";
						$rssText .= "	<docs>http://backend.userland.com/rss2</docs>\n";
						$rssText .= "	<pubDate>".$now."</pubDate>\n";
						$rssText .= "\n";
					}
					elseif ($type == "atom.03")
					{
						$atomID = "tag:".htmlspecialcharsbx($serverName).",".date("Y-m-d").":".$postID;

						$rssText .= "<"."?xml version=\"1.0\" encoding=\"".$charset."\"?".">\n\n";
						$rssText .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\" xml:lang=\"".$language."\">\n";
						$rssText .= "  <title>".$blogName."</title>\n";
						$rssText .= "  <tagline>".$url."</tagline>\n";
						$rssText .= "  <id>".$atomID."</id>\n";
						$rssText .= "  <link rel=\"alternate\" type=\"text/html\" href=\"".$url."\" />\n";
						$rssText .= "  <modified>".$nowISO."</modified>\n";

						$BlogUser = CBlogUser::GetByID($arPost["AUTHOR_ID"], BLOG_BY_USER_ID);
						$authorP = htmlspecialcharsex(CBlogUser::GetUserName($BlogUser["ALIAS"], $arUser["NAME"], $arUser["LAST_NAME"], $arUser["LOGIN"], $arUser["SECOND_NAME"]));
						if(strLen($arPathTemplate["PATH_TO_USER"])>0)
							$authorURLP = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_USER"], array("user_id"=>$arPost["AUTHOR_ID"])));
						else
							$authorURLP = "http://".$serverName.CBlogUser::PreparePath($arPost["AUTHOR_ID"], $arGroup["SITE_ID"]);

						$rssText .= "  <author>\n";
						$rssText .= "  		<name>".$authorP."</name>\n";
						$rssText .= "  		<uri>".$authorURLP."</uri>\n";
						$rssText .= "  </author>\n";

						$rssText .= "\n";
					}

					$user_id = $GLOBALS["USER"]->GetID();
					if($arPathTemplate["USE_SOCNET"] == "Y")
					{
						$postPerm = CBlogPost::GetSocNetPostPerms($postID);
						if($postPerm > BLOG_PERMS_DENY)
							$postPerm = CBlogComment::GetSocNetUserPerms($postID, $arPost["AUTHOR_ID"]);
					}
					else
						$postPerm = CBlogPost::GetBlogUserCommentPerms($postID, IntVal($user_id));

					if($postPerm >= BLOG_PERMS_READ)
					{
						$parser = new blogTextParser();
						$arParserParams = Array(
							"imageWidth" => $arPathTemplate["IMAGE_MAX_WIDTH"],
							"imageHeight" => $arPathTemplate["IMAGE_MAX_HEIGHT"],
						);

						CTimeZone::Disable();
						$dbComments = CBlogComment::GetList(
							array("DATE_CREATE" => "DESC"),
							array(
								//"BLOG_ID" => $blogID,
								"POST_ID" => $postID,
								"PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH,
							),
							false,
							array("nTopCount" => $numPosts),
							array("ID", "TITLE", "DATE_CREATE", "POST_TEXT", "AUTHOR_EMAIL", "AUTHOR_ID", "AUTHOR_NAME", "USER_LOGIN", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_NAME", "BLOG_USER_ALIAS")
						);
						CTimeZone::Enable();
						$arImages = Array();
						$dbImages = CBlogImage::GetList(Array(), Array("BLOG_ID" => $blogID, "POST_ID" => $postID, "IS_COMMENT" => "Y", "!COMMENT_ID" => false));
						while($arI = $dbImages->Fetch())
							$arImages[$arI["ID"]] = $arI["FILE_ID"];

						while ($arComments = $dbComments->Fetch())
						{
							$arDate = ParseDateTime($arComments["DATE_CREATE"], CSite::GetDateFormat("FULL", $arGroup["SITE_ID"]));
							$date = date("r", mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));

							if(strpos($url, "?") !== false)
								$url1 = $url."&amp;";
							else
								$url1 = $url."?";
							$url1 .= "commentId=".$arComments["ID"]."#".$arComments["ID"];

							$authorURL = "";
							if(IntVal($arComments["AUTHOR_ID"]) > 0)
							{
								$author = CBlogUser::GetUserName($arComments["BLOG_USER_ALIAS"], $arComments["USER_NAME"], $arComments["USER_LAST_NAME"], $arComments["USER_LOGIN"], $arComments["USER_SECOND_NAME"]);
								if(strLen($arPathTemplate["PATH_TO_USER"])>0)
									$authorURL = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_USER"], array("user_id"=>$arComments["AUTHOR_ID"])));
								else
									$authorURL = htmlspecialcharsbx("http://".$serverName.CBlogUser::PreparePath($arComments["AUTHOR_ID"], $arGroup["SITE_ID"]));
							}
							else
								$author = $arComments["AUTHOR_NAME"];
							$arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "TABLE" => "Y", "CUT_ANCHOR" => "N");
							if($arPathTemplate["NO_URL_IN_COMMENTS"] == "L" || (IntVal($arComments["AUTHOR_ID"]) <= 0  && $arPathTemplate["NO_URL_IN_COMMENTS"] == "A"))
								$arAllow["CUT_ANCHOR"] = "Y";

							if($arPathTemplate["NO_URL_IN_COMMENTS_AUTHORITY_CHECK"] == "Y" && $arAllow["CUT_ANCHOR"] != "Y" && IntVal($arComments["AUTHOR_ID"]) > 0)
							{
								$authorityRatingId = CRatings::GetAuthorityRating();
								$arRatingResult = CRatings::GetRatingResult($authorityRatingId, $arComments["AUTHOR_ID"]);
								if($arRatingResult["CURRENT_VALUE"] < $arPathTemplate["NO_URL_IN_COMMENTS_AUTHORITY"])
									$arAllow["CUT_ANCHOR"] = "Y";
							}

							$text = $parser->convert_to_rss($arComments["POST_TEXT"], $arImages, $arAllow, false, $arParserParams);

							$title = GetMessage("BLG_GCM_COMMENT_TITLE", Array("#POST_TITLE#" => htmlspecialcharsEx($arPost["TITLE"]), "#COMMENT_AUTHOR#" => htmlspecialcharsEx($author)));
							/*$title = str_replace(
								array("&", "<", ">", "\""),
								array("&amp;", "&lt;", "&gt;", "&quot;"),
								$title);
							*/
							//$text1 = HTMLToTxt($text, "", Array("\&nbsp;"), 60);
							$text = "<![CDATA[".$text."]]>";


							if ($type == "rss.92")
							{
								$rssText .= "    <item>\n";
								$rssText .= "      <title>".$title."</title>\n";
								$rssText .= "      <description>".$text."</description>\n";
								$rssText .= "      <link>".$url1."</link>\n";
								$rssText .= "    </item>\n";
								$rssText .= "\n";
							}
							elseif ($type == "rss2.0")
							{
								$rssText .= "    <item>\n";
								$rssText .= "      <title>".$title."</title>\n";
								$rssText .= "      <description>".$text."</description>\n";
								$rssText .= "      <link>".$url1."</link>\n";
								$rssText .= "      <guid>".$url1."</guid>\n";
								$rssText .= "      <pubDate>".$date."</pubDate>\n";
								$rssText .= "    </item>\n";
								$rssText .= "\n";
							}
							elseif ($type == "atom.03")
							{
								$atomID = "tag:".htmlspecialcharsbx($serverName).":".$arBlog["URL"]."/".$arPost["ID"];

								$timeISO = mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]);
								$dateISO = date("Y-m-d\TH:i:s", $timeISO).substr(date("O", $timeISO), 0, 3).":".substr(date("O", $timeISO), -2, 2);

								$rssText .= "<entry>\n";
								$rssText .= "  <title type=\"text/html\">".$title."</title>\n";
								$rssText .= "  <link rel=\"alternate\" type=\"text/html\" href=\"".$url1."\"/>\n";
								$rssText .= "  <issued>".$dateISO."</issued>\n";
								$rssText .= "  <modified>".$nowISO."</modified>\n";
								$rssText .= "  <id>".$atomID."</id>\n";
								$rssText .= "  <content type=\"text/html\" mode=\"escaped\" xml:lang=\"".$language."\" xml:base=\"".$blogURL."\">\n";
								$rssText .= $text."\n";
								$rssText .= "  </content>\n";
								$rssText .= "  <author>\n";
								$rssText .= "    <name>".htmlspecialcharsex($author)."</name>\n";
								if(strlen($authorURL) > 0)
									$rssText .= "    <uri>".$authorURL."</uri>\n";
								$rssText .= "  </author>\n";
								$rssText .= "</entry>\n";
								$rssText .= "\n";
							}
						}
					}

					if ($type == "rss.92")
						$rssText .= "  </channel>\n</rss>";
					elseif ($type == "rss2.0")
						$rssText .= "  </channel>\n</rss>";
					elseif ($type == "atom.03")
						$rssText .= "\n\n</feed>";
				}
			}
		}

		return $rssText;
	}
Ejemplo n.º 7
0
function FormatDateEx($strDate, $format=false, $new_format=false)
{
	$strDate = trim($strDate);

	if (false === $format) $format = CSite::GetDateFormat('FULL');
	if (false === $new_format) $new_format = CSite::GetDateFormat('FULL');

	$new_format = str_replace("MI","I", $new_format);
	$new_format = preg_replace("/([DMYIHGST])\\1+/is".BX_UTF_PCRE_MODIFIER, "\\1", $new_format);
	$arFormat = preg_split('/[^0-9A-Za-z]/', strtoupper($format));
	$arDate = preg_split('/[^A-Za-z0-9]/', $strDate);

	$arParsedDate = ParseDateTime($strDate);

	if (isset($arParsedDate["MMMM"]))
	{
		if (is_numeric($arParsedDate["MMMM"]))
		{
			$arParsedDate["MM"] = intval($arParsedDate["MMMM"]);
		}
		else
		{
			$arParsedDate["MM"] = GetNumMonth($arParsedDate["MMMM"]);
			if (!$arParsedDate["MM"])
				$arParsedDate["MM"] = intval(date('m', strtotime($arParsedDate["MMMM"])));
		}
	}
	elseif (isset($arParsedDate["MM"]))
	{
		$arParsedDate["MM"] = intval($arParsedDate["MM"]);
	}
	elseif (isset($arParsedDate["M"]))
	{
		if (is_numeric($arParsedDate["M"]))
		{
			$arParsedDate["MM"] = intval($arParsedDate["M"]);
		}
		else
		{
			$arParsedDate["MM"] = GetNumMonth($arParsedDate["M"], true);
			if (!$arParsedDate["MM"])
				$arParsedDate["MM"] = intval(date('m', strtotime($arParsedDate["M"])));
		}
	}


	if (isset($arParsedDate["H"]))
	{
		$arParsedDate["HH"] = intval($arParsedDate["H"]);
	}
	elseif (isset($arParsedDate["GG"]))
	{
		$arParsedDate["HH"] = intval($arParsedDate["GG"]);
	}
	elseif (isset($arParsedDate["G"]))
	{
		$arParsedDate["HH"] = intval($arParsedDate["G"]);
	}

	if (isset($arParsedDate['TT']) || isset($arParsedDate['T']))
	{
		$middletime = isset($arParsedDate['TT']) ? $arParsedDate['TT'] : $arParsedDate['T'];
		if (strcasecmp('pm', $middletime)===0)
		{
			if ($arParsedDate["HH"] < 12)
				$arParsedDate["HH"] += 12;
			else
				$arParsedDate["HH"] -= 12;
		}
	}

	if (isset($arParsedDate["YYYY"]))
		$arParsedDate["YY"] = $arParsedDate["YYYY"];

	if (intval($arParsedDate["DD"])<=0 || intval($arParsedDate["MM"])<=0 || intval($arParsedDate["YY"])<=0)
		return false;

	$strResult = "";

	if(intval($arParsedDate["YY"])>1970 && intval($arParsedDate["YY"])<2038)
	{
		$ux_time = mktime(
				intval($arParsedDate["HH"]),
				intval($arParsedDate["MI"]),
				intval($arParsedDate["SS"]),
				intval($arParsedDate["MM"]),
				intval($arParsedDate["DD"]),
				intval($arParsedDate["YY"])
				);

		for ($i=0; $i<strlen($new_format); $i++)
		{
			$simbol = substr($new_format, $i ,1);
			switch ($simbol)
			{
				case "F":$match=GetMessage("MONTH_".date("n", $ux_time)."_S");break;
				case "f":$match=GetMessage("MONTH_".date("n", $ux_time));break;
				case "M":$match=GetMessage("MON_".date("n", $ux_time));break;
				case "l":$match=GetMessage("DAY_OF_WEEK_".date("w", $ux_time));break;
				case "D":$match=GetMessage("DOW_".date("w", $ux_time));break;
				default: $match = date(substr($new_format, $i ,1), $ux_time); break;
			}
			$strResult .= $match;
		}
	}
	else
	{
		if($arParsedDate["MM"]<1 || $arParsedDate["MM"]>12)
			$arParsedDate["MM"] = 1;
		for ($i=0; $i<strLen($new_format); $i++)
		{
			$simbol = substr($new_format, $i ,1);
			switch ($simbol)
			{
				case "F":
				case "f":
					$match = str_pad($arParsedDate["MM"], 2, "0", STR_PAD_LEFT);
					if (intVal($arParsedDate["MM"]) > 0)
						$match=GetMessage("MONTH_".intVal($arParsedDate["MM"]).($simbol == 'F' ? '_S' : ''));
					break;
				case "M":
					$match = str_pad($arParsedDate["MM"], 2, "0", STR_PAD_LEFT);
					if (intVal($arParsedDate["MM"]) > 0)
						$match=GetMessage("MON_".intVal($arParsedDate["MM"]));
					break;
				case "l":
					$match = str_pad($arParsedDate["DD"], 2, "0", STR_PAD_LEFT);
					if (intVal($arParsedDate["DD"]) > 0)
						$match = GetMessage("DAY_OF_WEEK_".intVal($arParsedDate["DD"]));
					break;
				case "D":
					$match = str_pad($arParsedDate["DD"], 2, "0", STR_PAD_LEFT);
					if (intVal($arParsedDate["DD"]) > 0)
						$match = GetMessage("DOW_".intVal($arParsedDate["DD"]));
					break;
				case "d": $match = str_pad($arParsedDate["DD"], 2, "0", STR_PAD_LEFT); break;
				case "m": $match = str_pad($arParsedDate["MM"], 2, "0", STR_PAD_LEFT); break;
				case "j": $match = intVal($arParsedDate["DD"]); break;
				case "Y": $match = str_pad($arParsedDate["YY"], 4, "0", STR_PAD_LEFT); break;
				case "y": $match = substr($arParsedDate["YY"], 2);break;
				case "H": $match = str_pad($arParsedDate["HH"], 2, "0", STR_PAD_LEFT); break;
				case "i": $match = str_pad($arParsedDate["MI"], 2, "0", STR_PAD_LEFT); break;
				case "s": $match = str_pad($arParsedDate["SS"], 2, "0", STR_PAD_LEFT); break;
				case "g":
					$match = intVal($arParsedDate["HH"]);
					if ($match > 12)
						$match = $match-12;
				case "a":
				case "A":
					$match = intVal($arParsedDate["HH"]);
					if ($match > 12)
						$match = ($match-12)." PM";
					else
						$match .= " AM";

					if (substr($new_format, $i ,1) == "a")
						$match = strToLower($match);

				default: $match = substr($new_format, $i ,1); break;
			}
			$strResult .= $match;
		}
	}
	return $strResult;
}
Ejemplo n.º 8
0
 case 'PERSONAL_PHONE':
 case 'PERSONAL_FAX':
 case 'PERSONAL_MOBILE':
 case 'WORK_PHONE':
 case 'WORK_FAX':
     if (StrLen($val) > 0) {
         $valEncoded = preg_replace('/[^\\d\\+]+/', '', htmlspecialcharsbx($val));
         $val = '<a href="callto:' . $valEncoded . '">' . htmlspecialcharsbx($val) . '</a>';
     }
     break;
 case 'PERSONAL_GENDER':
     $val = $val == 'F' ? GetMessage("MAIN_UL_SEX_F") : ($val == 'M' ? GetMessage("MAIN_UL_SEX_M") : "");
     break;
 case 'PERSONAL_BIRTHDAY':
     if (StrLen($val) > 0) {
         $arDateTmp = ParseDateTime($val, CSite::GetDateFormat('SHORT'));
         $day = IntVal($arDateTmp["DD"]);
         $month = IntVal($arDateTmp["MM"]);
         $year = IntVal($arDateTmp["YYYY"]);
         $val = $day . ' ' . ToLower(GetMessage('MONTH_' . $month . '_S'));
         if ($arParams['SHOW_YEAR'] == 'Y' || $arParams['SHOW_YEAR'] == 'M' && $arResult["User"]['PERSONAL_GENDER'] == 'M') {
             $val .= ' ' . $year;
         }
         $arResult['IS_BIRTHDAY'] = intval($arDateTmp['MM']) == date('n') && intval($arDateTmp['DD']) == date('j');
     }
     break;
 case 'WORK_LOGO':
     if (IntVal($val) > 0) {
         $iSize = 150;
         $imageFile = CFile::GetFileArray($val);
         if ($imageFile !== false) {
Ejemplo n.º 9
0
 /**
  * @param $date
  * @return int
  */
 public static function timestamp($time)
 {
     if (preg_match('{^\\d+$}', $time)) {
         return $time;
     }
     if ($m = \ParseDateTime($time)) {
         return mktime($m['HH'], $m['MI'], $m['SS'], $m['MM'], $m['DD'], $m['YYYY']);
     }
     return time();
 }
Ejemplo n.º 10
0
 /**
  * Creates filter for CSaleOrder::GetList() based on $_REQUEST and other parameters
  * @return void
  */
 protected function prepareFilter()
 {
     global $USER;
     global $DB;
     $arFilter = array();
     $arFilter["USER_ID"] = $USER->GetID();
     $arFilter["LID"] = SITE_ID;
     if (strlen($_REQUEST["filter_id"])) {
         if ($this->options['USE_ACCOUNT_NUMBER']) {
             $arFilter["ACCOUNT_NUMBER"] = $_REQUEST["filter_id"];
         } else {
             $arFilter["ID"] = intval($_REQUEST["filter_id"]);
         }
     }
     if (strlen($_REQUEST["filter_date_from"])) {
         $arFilter["DATE_FROM"] = trim($_REQUEST["filter_date_from"]);
     }
     if (strlen($_REQUEST["filter_date_to"])) {
         $arFilter["DATE_TO"] = trim($_REQUEST["filter_date_to"]);
         if ($arDate = ParseDateTime(trim($_REQUEST["filter_date_to"]), $this->dateFormat)) {
             if (StrLen(trim($_REQUEST["filter_date_to"])) < 11) {
                 $arDate["HH"] = 23;
                 $arDate["MI"] = 59;
                 $arDate["SS"] = 59;
             }
             $arFilter["DATE_TO"] = date($DB->DateFormatToPHP($this->dateFormat), mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
         }
     }
     if (strlen($_REQUEST["filter_status"])) {
         $arFilter["STATUS_ID"] = trim($_REQUEST["filter_status"]);
     }
     if (strlen($_REQUEST["filter_payed"])) {
         $arFilter["PAYED"] = trim($_REQUEST["filter_payed"]);
     }
     if (!isset($_REQUEST['show_all']) || $_REQUEST['show_all'] == 'N') {
         if ($_REQUEST["filter_history"] != "Y") {
             $arFilter["!@COMPLETE_ORDERS"] = $this->arParams['HISTORIC_STATUSES'];
         }
         if (isset($_REQUEST["filter_history"]) && $_REQUEST["filter_history"] == "Y") {
             $arFilter["@COMPLETE_ORDERS"] = $this->arParams['HISTORIC_STATUSES'];
         }
     }
     if (strlen($_REQUEST["filter_canceled"])) {
         $arFilter["CANCELED"] = trim($_REQUEST["filter_canceled"]);
     }
     $this->filter = $arFilter;
 }
Ejemplo n.º 11
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$arParams["SEARCH_FILTER_NAME"] = isset($arParams["SEARCH_FILTER_NAME"]) && strlen($arParams["SEARCH_FILTER_NAME"]) > 0 ? $arParams["SEARCH_FILTER_NAME"] : "sonet_search_filter";
$arParams["SEARCH_FILTER_DATE_NAME"] = isset($arParams["SEARCH_FILTER_DATE_NAME"]) && strlen($arParams["SEARCH_FILTER_DATE_NAME"]) > 0 ? $arParams["SEARCH_FILTER_DATE_NAME"] : "sonet_search_filter_date";
$arParams["SEARCH_RESTART"] = isset($arParams["SEARCH_RESTART"]) && $arParams["SEARCH_RESTART"] == "Y" ? $arParams["SEARCH_RESTART"] : "N";
$arParams["SEARCH_USE_LANGUAGE_GUESS"] = isset($arParams["SEARCH_USE_LANGUAGE_GUESS"]) && $arParams["SEARCH_USE_LANGUAGE_GUESS"] == "N" ? $arParams["SEARCH_USE_LANGUAGE_GUESS"] : "Y";
global ${$arParams["SEARCH_FILTER_NAME"]}, $sonet_search_settings;
$sonet_search_filter = array();
$EntityType = strpos($componentPage, "group_content_search") !== false ? SONET_ENTITY_GROUP : SONET_ENTITY_USER;
$sFilterDateTo = $_REQUEST[$arParams["SEARCH_FILTER_DATE_NAME"] . "_to"];
if ($arr = ParseDateTime($_REQUEST[$arParams["SEARCH_FILTER_DATE_NAME"] . "_to"])) {
    if (intval($arr["HH"]) == 0 && intval($arr["MI"]) == 0 && intval($arr["SS"]) == 0) {
        $arr["HH"] = "23";
        $arr["MI"] = "59";
        $arr["SS"] = "59";
        $sDateTime = $arr["DD"] . "." . $arr["MM"] . "." . $arr["YYYY"] . " " . $arr["HH"] . ":" . $arr["MI"] . ":" . $arr["SS"];
        $stmp = MakeTimeStamp($sDateTime, "DD.MM.YYYY HH:MI:SS");
        $sFilterDateTo = ConvertTimeStamp($stmp, "FULL");
    }
}
if (strlen($_REQUEST[$arParams["SEARCH_FILTER_NAME"]]) > 0) {
    $sonet_search_filter["SONET_FEATURE"] = $_REQUEST[$arParams["SEARCH_FILTER_NAME"]];
}
if (strlen($_REQUEST[$arParams["SEARCH_FILTER_DATE_NAME"] . "_from"]) > 0) {
    $sonet_search_filter[">=DATE_CHANGE"] = $_REQUEST[$arParams["SEARCH_FILTER_DATE_NAME"] . "_from"];
}
if (strlen($sFilterDateTo) > 0) {
    $sonet_search_filter["<=DATE_CHANGE"] = $sFilterDateTo;
Ejemplo n.º 12
0
 public static function CronRun($profileID, $setup, $delete_cron = false)
 {
     $path2export = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/php_interface/include/exportpro/";
     $logPath = $_SERVER["DOCUMENT_ROOT"] . "/upload/exportpro_log/";
     $cron_period = intval($setup["PERIOD"]);
     $dirExport = !preg_match("/.+\\..{3,}/", $setup["URL_DATA_FILE"], $arMatches);
     if ($dirExport) {
         $path2export = $_SERVER["DOCUMENT_ROOT"] . $setup["URL_DATA_FILE"];
     }
     // Получаем список записей в crontab
     $cfg_data = "";
     $cron_list = array();
     @exec("crontab -l", $cron_list);
     CheckDirPath($path2export);
     CheckDirPath($logPath);
     $datetime = $setup["DAT_START"];
     $format = CSite::GetDateFormat();
     $date = ParseDateTime($datetime, $format);
     $starttime = intval($date["HH"]);
     $cronTime = array();
     if ($cron_period <= 0) {
         $cronTime[] = intval($date["MI"]) . " " . intval($date["HH"]) . " " . intval($date["DD"]) . " " . intval($date["MM"]) . " * ";
     } elseif ($cron_period < 24) {
         $cronHours = array($starttime);
         for ($i = 0; $i < 24; $i++) {
             $starttime += $cron_period;
             $starttime = $starttime > 23 ? $starttime - 24 : $starttime;
             $cronHours[] = $starttime;
         }
         sort($cronHours);
         $cronHours = array_unique($cronHours);
         $cronTime[] = intval($date["MI"]) . " " . implode(",", $cronHours) . " * * * ";
     } elseif ($cron_period > 23 && $cron_period < 720) {
         $cron_period_mod = $cron_period % 24;
         $cron_period_div = intval($cron_period / 24);
         if ($cron_period_mod == 0) {
             $cron_period_div--;
             $i = 2;
         } else {
             $i = 1;
         }
         $dateVal = 1 + $date["DD"] - 1;
         $dateVal = $dateVal > 30 ? $dateVal - 30 : $dateVal;
         $cronDaysHours = array($starttime => array($dateVal));
         for ($i; $i < 31; $i++) {
             $i += $cron_period_div;
             $starttime += $cron_period_mod;
             if ($starttime > 23) {
                 $starttime = $starttime - 24;
                 $i++;
             }
             $dateVal = $i + $date["DD"] - 1;
             $dateVal = $dateVal > 30 ? $dateVal - 30 : $dateVal;
             $cronDaysHours[$starttime][] = $dateVal;
         }
         foreach ($cronDaysHours as $hour => $days) {
             $cronTime[] = intval($date["MI"]) . " " . $hour . " " . implode(",", $days) . " * * ";
         }
     }
     foreach ($cron_list as $id => $cronRecord) {
         if (strpos($cronRecord, "/acrit.exportpro/tools/cronrun.php {$profileID}")) {
             unset($cron_list[$id]);
         }
     }
     //$dateStart = ParseDateTime( $setup["DAT_START"], CSite::GetDateFormat( "FULL" ) );
     //$strTimeNow = "{$dateStart["MI"]} {$dateStart["HH"]} {$dateStart["DD"]} {$dateStart["MM"]} *";
     if (!$delete_cron) {
         foreach ($cronTime as $strTime) {
             $cron_list[] = "{$strTime} php -f {$_SERVER["DOCUMENT_ROOT"]}/bitrix/modules/acrit.exportpro/tools/cronrun.php {$profileID} \"{$_SERVER["DOCUMENT_ROOT"]}\"";
         }
     }
     CheckDirPath($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/");
     file_put_contents($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg", implode(PHP_EOL, $cron_list) . PHP_EOL);
     // Записываем новое значение в crontab
     @exec("crontab " . $_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg");
 }
Ejemplo n.º 13
0
      }else{
          $arComments = CCommentEx::getList(array("UF_USER_ID"=>$USER_ID, "UF_TEXT"=>$text, "UF_PROG_ID" => $prog_id), array("ID"));
      }*/
    $rsUser = CUser::GetByID($USER_ID);
    $arUser = $rsUser->Fetch();
    /*if(count($arComments)>0)
      {
          $result = array(
               "status" => "warning",
               "username" => trim($arUser["NAME"]." ".$arUser["LAST_NAME"]),
               "user_photo" => CFile::GetPath($arUser["PERSONAL_PHOTO"]),
               "publish_date" => $arDATE["DD"]." ".ToLower(GetMessage("MONTH_".intval($arDATE["MM"])."_S"))." ".$arDATE["YYYY"],
               "comment_text" => $text,
               "message"      => "Такой комментарий уже добавлен вами."
          );
      }
      else
      {*/
    $arDATE = ParseDateTime(date("d.m.Y"), FORMAT_DATETIME);
    $res = CCommentEx::create(array("TEXT" => $text, "PROG_ID" => $prog_id));
    if ($res === true) {
        $result = array("status" => "success", "username" => trim($arUser["NAME"] . " " . $arUser["LAST_NAME"]), "user_avatar" => CFile::GetPath($arUser["PERSONAL_PHOTO"]), "publish_date" => $arDATE["DD"] . " " . ToLower(GetMessage("MONTH_" . intval($arDATE["MM"]) . "_S")) . " " . $arDATE["YYYY"], "comment_text" => $text);
    } else {
        $result["message"] = $res;
    }
    //}
} else {
    $result["message"] = 'Введите сообщение.';
}
exit(json_encode($result));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
Ejemplo n.º 14
0
    if (strlen($_SESSION["spo_filter_canceled"]) > 0) {
        $_REQUEST["filter_canceled"] = $_SESSION["spo_filter_canceled"];
    }
    if ($_SESSION["spo_filter_history"] == "Y") {
        $_REQUEST["filter_history"] == "Y";
    }
}
if (IntVal($_REQUEST["filter_id"]) > 0) {
    $arFilter["ID"] = IntVal($_REQUEST["filter_id"]);
}
if (strlen($_REQUEST["filter_date_from"]) > 0) {
    $arFilter["DATE_FROM"] = Trim($_REQUEST["filter_date_from"]);
}
if (strlen($_REQUEST["filter_date_to"]) > 0) {
    $arFilter["DATE_TO"] = Trim($_REQUEST["filter_date_to"]);
    if ($arDate = ParseDateTime(Trim($_REQUEST["filter_date_to"]), CSite::GetDateFormat("FULL", SITE_ID))) {
        if (StrLen(Trim($_REQUEST["filter_date_to"])) < 11) {
            $arDate["HH"] = 23;
            $arDate["MI"] = 59;
            $arDate["SS"] = 59;
        }
        $arFilter["DATE_TO"] = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
    }
}
if (strlen($_REQUEST["filter_status"]) > 0) {
    $arFilter["STATUS_ID"] = Trim($_REQUEST["filter_status"]);
}
if (strlen($_REQUEST["filter_payed"]) > 0) {
    $arFilter["PAYED"] = Trim($_REQUEST["filter_payed"]);
}
if ($_REQUEST["filter_history"] != "Y") {
Ejemplo n.º 15
0
if (count($arResult["COMMENTS"]) > 0) {
    ?>
 in<?php 
}
?>
">
		<div class="block-header">
			<h3 class="block-title">Отзывы</h3>
		</div>
		<div class="block-body">
			<ul class="comments-list">
                <?php 
foreach ($arResult["COMMENTS"] as $arComment) {
    $arUser = $arResult["USERS"][$arComment["UF_USER_ID"]];
    $date = $arComment['UF_DATETIME']->toString();
    $arDATE = ParseDateTime($date, FORMAT_DATETIME);
    ?>
                    <li>
    					<div class="user-avatar<?php 
    if (!$arUser["PERSONAL_PHOTO"]) {
        ?>
 is-empty<?php 
    }
    ?>
">
    						<?php 
    if ($arUser["PERSONAL_PHOTO"]) {
        ?>
                                <img src="<?php 
        echo CFile::GetPath($arUser["PERSONAL_PHOTO"]);
        ?>
Ejemplo n.º 16
0
 } else {
     $defaultClassName = "NewsCalDefault";
 }
 $arDay["day"] = $d;
 $arDay["td_class"] = $defaultClassName;
 $arDay["tday_class"] = $dayClassName;
 $arDay["events"] = array();
 $tmpDate = date($DB->DateFormatToPHP(CLang::GetDateFormat("SHORT")), mktime(0, 0, 0, $m, $d, $y));
 if (is_set($arDays[$tmpDate])) {
     $nn = 0;
     foreach ($arDays[$tmpDate] as $dayNews) {
         $nn++;
         $eTime = "";
         $arTime = array();
         if ($arParams["SHOW_TIME"]) {
             $arTime = ParseDateTime($dayNews["DATE_ACTIVE_FROM"], CLang::GetDateFormat("FULL"));
             if (IntVal($arTime["HH"]) > 0 || $arTime["MI"] > 0) {
                 $eTime = $arTime["HH"] . ":" . $arTime["MI"] . "&nbsp;";
             }
         }
         if ($dayNews["PREVIEW_TEXT_TYPE"] == "text" && strlen($dayNews["PREVIEW_TEXT"]) > 0) {
             $sTitle = TruncateText($dayNews["PREVIEW_TEXT"], 100);
         } else {
             $sTitle = $dayNews["NAME"];
         }
         if ($arParams["TITLE_LEN"] > 0) {
             $title = TruncateText($dayNews["NAME"], $arParams["TITLE_LEN"]);
         } else {
             $title = $dayNews["NAME"];
         }
         $arDay["events"][] = array("time" => $eTime, "url" => $dayNews["DETAIL_PAGE_URL"], "title" => $title, "preview" => $sTitle, $arParams["DATE_FIELD"] => $dayNews[$arParams["DATE_FIELD"]]);
Ejemplo n.º 17
0
 public static function isShortDate($strDate)
 {
     $arDate = ParseDateTime($strDate, FORMAT_DATETIME);
     unset($arDate["DD"]);
     unset($arDate["MMMM"]);
     unset($arDate["MM"]);
     unset($arDate["M"]);
     unset($arDate["YYYY"]);
     return array_sum($arDate) == 0;
 }
Ejemplo n.º 18
0
                 $suffix = "male";
                 break;
             case "F":
                 $suffix = "female";
                 break;
             default:
                 $suffix = "unknown";
         }
         $arFriends["PERSONAL_PHOTO"] = COption::GetOptionInt("socialnetwork", "default_user_picture_" . $suffix, false, SITE_ID);
     }
     $arImage = CSocNetTools::InitImage($arFriends["PERSONAL_PHOTO"], $arParams["THUMBNAIL_LIST_SIZE"], "/bitrix/images/socialnetwork/nopic_30x30.gif", 30, $pu, $canViewProfile);
 } else {
     // old
     $arImage = CSocNetTools::InitImage($arFriends["PERSONAL_PHOTO"], 50, "/bitrix/images/socialnetwork/nopic_user_50.gif", 50, $pu, $canViewProfile);
 }
 $arDateTmp = ParseDateTime($arFriends["PB"], "YYYY-MM-DD");
 $day = IntVal($arDateTmp["DD"]);
 $month = IntVal($arDateTmp["MM"]);
 $year = IntVal($arDateTmp["YYYY"]);
 if ($day <= 0) {
     continue;
 }
 if ($arResult["Users"]["List"] == false) {
     $arResult["Users"]["List"] = array();
 }
 $val = $day . ' ' . ToLower(GetMessage('MONTH_' . $month . '_S'));
 $arResult["Users"]["List"][] = array("ID" => $arFriends["ID"], "NAME" => $arFriends["NAME"], "LAST_NAME" => $arFriends["LAST_NAME"], "SECOND_NAME" => $arFriends["SECOND_NAME"], "LOGIN" => $arFriends["LOGIN"], "PERSONAL_PHOTO" => $arFriends["PERSONAL_PHOTO"], "PERSONAL_PHOTO_FILE" => $arImage["FILE"], "PERSONAL_PHOTO_IMG" => $arImage["IMG"], "PROFILE_URL" => $pu, "SHOW_PROFILE_LINK" => $canViewProfile, "BIRTHDAY" => $val, "NOW" => $nowDay == $day && $nowMonth == $month, "IS_ONLINE" => $arFriends["IS_ONLINE"] == "Y");
 $cnt++;
 if ($cnt > $arParams["ITEMS_COUNT"]) {
     break;
 }
Ejemplo n.º 19
0
 /**
  * <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));
 }
Ejemplo n.º 20
0
 $cache_id = md5(serialize(array("forum_userbirthday_" . preg_replace("/\\s.,;:!?\\#\\-\\*\\|\\[\\]\\(\\)\\//is", "_", $arParams["URL_TEMPLATES_PROFILE_VIEW"]), date("m-d"), CTimeZone::GetOffset())));
 $cache_path = $cache_path_main . "birthday/";
 $BIRTHDAY_CACHE_TIME = 60 * 60 * 24;
 if ($arParams["CACHE_TIME"] > 0 && $cache->InitCache($BIRTHDAY_CACHE_TIME, $cache_id, $cache_path)) {
     $res = $cache->GetVars();
     $arTTL = getdate();
     $TTL = mktime(0, 0, 0, $arTTL['mon'], $arTTL['mday'], $arTTL['year']);
     if (is_array($res["arUserBirthday"]) && isset($res['timestamp']) && $TTL < $res['timestamp'] + $BIRTHDAY_CACHE_TIME) {
         $arUserBirthday = $res["arUserBirthday"];
     }
 } else {
     $db_res = CForumUser::GetList(array(), array("ACTIVE" => "Y", "PERSONAL_BIRTHDAY_DATE" => Date("m-d"), ">=USER_ID" => 1, "SHOW_ABC" => ""), array("sNameTemplate" => $arParams["NAME_TEMPLATE"]));
     if ($db_res && ($res = $db_res->GetNext())) {
         do {
             $res["SHOW_NAME"] = $parser->wrap_long_words($res["SHOW_ABC"]);
             $date_birthday = ParseDateTime($res["PERSONAL_BIRTHDAY"]);
             $res["AGE"] = intVal(date("Y")) - intVal($date_birthday["YYYY"]);
             $res["profile_view"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $res["USER_ID"]));
             $arUserBirthday[] = $res;
         } while ($res = $db_res->GetNext());
     }
     if ($arParams["CACHE_TIME"] > 0) {
         $cache->StartDataCache($BIRTHDAY_CACHE_TIME, $cache_id, $cache_path);
         $arTTL = getdate();
         $TTL = mktime(0, 0, 0, $arTTL['mon'], $arTTL['mday'], $arTTL['year']);
         $cache->EndDataCache(array("arUserBirthday" => $arUserBirthday, "timestamp" => $TTL));
     }
 }
 if (is_array($arUserBirthday)) {
     $arResult["USERS_BIRTHDAY"] = $arUserBirthday;
 }
Ejemplo n.º 21
0
 public function addLastTimeToDate($strDate)
 {
     $retStrDateTime = '';
     if (strlen($strDate) <= 0) {
         return $retStrDateTime;
     }
     if ($arDate = ParseDateTime($strDate, CSite::GetDateFormat("FULL", SITE_ID))) {
         if (StrLen($strDate) < 11) {
             $arDate["HH"] = 23;
             $arDate["MI"] = 59;
             $arDate["SS"] = 59;
         }
         $retStrDateTime = date($GLOBALS["DB"]->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
     }
     return $retStrDateTime;
 }
Ejemplo n.º 22
0
 public static function GetTelephonyStatistic()
 {
     $arMonthlyStat = COption::GetOptionString("voximplant", "telephony_statistic", "");
     if ($arMonthlyStat) {
         $arMonthlyStat = unserialize($arMonthlyStat);
     } else {
         $arMonthlyStat = array();
     }
     $lastUncountedMonth = COption::GetOptionString("voximplant", "telephony_statistic_last_month", "");
     //last month which wasn't counted
     if ($lastUncountedMonth) {
         $lastUncountedMonth = unserialize($lastUncountedMonth);
     } else {
         $lastUncountedMonth = array();
     }
     $curLastMonth = array();
     $curLastMonth["MM"] = date("m");
     $curLastMonth["YYYY"] = date("Y");
     if (date("m") != $lastUncountedMonth["MM"] || date("Y") != $lastUncountedMonth["YYYY"]) {
         $firstDayCurMonth = ConvertTimeStamp(MakeTimeStamp("01." . date("m") . "." . date("Y"), "DD.MM.YYYY"));
         if (!empty($lastUncountedMonth)) {
             $firstUncountedDay = ConvertTimeStamp(MakeTimeStamp("01." . $lastUncountedMonth["MM"] . "." . $lastUncountedMonth["YYYY"], "DD.MM.YYYY"));
             $arFilter = array(array('LOGIC' => 'AND', '>CALL_START_DATE' => $firstUncountedDay, '<CALL_START_DATE' => $firstDayCurMonth));
         } else {
             $arFilter = array(array('LOGIC' => 'AND', '>CALL_START_DATE' => ConvertTimeStamp(MakeTimeStamp("04.02.2014", "DD.MM.YYYY")), '<CALL_START_DATE' => $firstDayCurMonth));
         }
         $arFilter['CALL_CATEGORY'] = 'external';
         $parameters = array('order' => array('CALL_START_DATE' => 'DESC'), 'filter' => $arFilter, 'select' => array('COST', 'COST_CURRENCY', 'CALL_DURATION', 'CALL_START_DATE'));
         $dbStat = VI\StatisticTable::getList($parameters);
         $curPortalCurrency = "";
         while ($arData = $dbStat->fetch()) {
             $arData["COST_CURRENCY"] = $arData["COST_CURRENCY"] == "RUR" ? "RUB" : $arData["COST_CURRENCY"];
             if (!$curPortalCurrency) {
                 $curPortalCurrency = $arData["COST_CURRENCY"];
             }
             $arDateParse = ParseDateTime($arData["CALL_START_DATE"]);
             $arMonthlyStat[$arDateParse["YYYY"]][$arDateParse["MM"]]["CALL_DURATION"] += $arData["CALL_DURATION"];
             $arMonthlyStat[$arDateParse["YYYY"]][$arDateParse["MM"]]["COST"] += $arData["COST"];
             //		$arMonthlyStat[$arDateParse["YYYY"]][$arDateParse["MM"]]["COST"] = number_format($arMonthlyStat[$arDateParse["YYYY"]][$arDateParse["MM"]]["COST"], 4);
             $arMonthlyStat[$arDateParse["YYYY"]][$arDateParse["MM"]]["COST_CURRENCY"] = $curPortalCurrency;
         }
         if (!empty($arMonthlyStat)) {
             krsort($arMonthlyStat);
             foreach ($arMonthlyStat as $year => $arYear) {
                 krsort($arYear);
                 $arMonthlyStat[$year] = $arYear;
             }
             COption::SetOptionString("voximplant", "telephony_statistic", serialize($arMonthlyStat));
             COption::SetOptionString("voximplant", "telephony_statistic_last_month", serialize($curLastMonth));
         }
     }
     return $arMonthlyStat;
 }
Ejemplo n.º 23
0
        if (StrLen($filter_date_insert_to) < 11) {
            $arDate["HH"] = 23;
            $arDate["MI"] = 59;
            $arDate["SS"] = 59;
        }
        $filter_date_insert_to = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
        $arFilter["<=DATE_INSERT"] = $filter_date_insert_to;
    } else {
        $filter_date_insert_to = "";
    }
}
if (strlen($filter_date_update_from) > 0) {
    $arFilter[">=DATE_UPDATE"] = Trim($filter_date_update_from);
}
if (strlen($filter_date_update_to) > 0) {
    if ($arDate = ParseDateTime($filter_date_update_to, CSite::GetDateFormat("FULL", SITE_ID))) {
        if (StrLen($filter_date_update_to) < 11) {
            $arDate["HH"] = 23;
            $arDate["MI"] = 59;
            $arDate["SS"] = 59;
        }
        $filter_date_update_to = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
        $arFilter["<=DATE_UPDATE"] = $filter_date_update_to;
    } else {
        $filter_date_update_to = "";
    }
}
if (strlen($filter_product_id) > 0) {
    $arFilter["PRODUCT_ID"] = $filter_product_id;
}
if (is_array($filter_lang) && count($filter_lang) > 0) {
Ejemplo n.º 24
0
     $res["SIGNATURE"] = $parser->convert_to_rss($res["~SIGNATURE"], $arAllow);
 }
 /************** Author info/****************************************/
 $res["~AUTHOR_LINK"] = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PROFILE_VIEW"], array("UID" => intVal($res["AUTHOR_ID"])));
 $res["AUTHOR_LINK"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("UID" => intVal($res["AUTHOR_ID"])));
 $res["~POST_LINK"] = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["TOPIC_ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => $res["ID"]));
 $res["POST_LINK"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["TOPIC_ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => $res["ID"]));
 $res["~AUTHOR_URL"] = "http://" . $arResult["SERVER_NAME"] . $res["~AUTHOR_LINK"];
 $res["AUTHOR_URL"] = "http://" . htmlspecialcharsEx($arResult["SERVER_NAME"]) . $res["AUTHOR_LINK"];
 $res["~URL"] = "http://" . $arResult["SERVER_NAME"] . $res["~POST_LINK"];
 $res["URL"] = "http://" . htmlspecialcharsEx($arResult["SERVER_NAME"]) . $res["POST_LINK"];
 $res["~URL_RSS"] = "http://" . $arResult["SERVER_NAME"] . CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_RSS"], array("TYPE" => strToLower($arParams["TYPE"]), "MODE" => "topic", "IID" => $res["TOPIC_ID"]));
 $res["URL_RSS"] = "http://" . htmlspecialcharsEx($arResult["SERVER_NAME"]) . CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_RSS"], array("TYPE" => strToLower($arParams["TYPE"]), "MODE" => "topic", "IID" => $res["TOPIC_ID"]));
 $res["UUID"] = __create_uuid($res["~URL"]);
 // TOPIC DATA
 $arDate = ParseDateTime($res["START_DATE"], false);
 $date = date("r", mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
 if ($arParams["TYPE"] == "ATOM") {
     $timeISO = mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]);
     $date = date("Y-m-d\\TH:i:s", $timeISO) . substr(date("O", $timeISO), 0, 3) . ":" . substr(date("O", $timeISO), -2, 2);
 }
 $topic = array("ID" => $res["TOPIC_ID"], "TITLE" => $res["TITLE"], "~TITLE" => $res["~TITLE"], "DESCRIPTION" => $res["TOPIC_DESCRIPTION"], "~DESCRIPTION" => $res["~TOPIC_DESCRIPTION"], "TOPIC_DESCRIPTION" => $res["TOPIC_DESCRIPTION"], "~TOPIC_DESCRIPTION" => $res["~TOPIC_DESCRIPTION"], "START_DATE" => $date, "~START_DATE" => $res["~START_DATE"], "START_DATE_FORMATED" => CForumFormat::DateFormat($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($res["~START_DATE"], CSite::GetDateFormat())), "AUTHOR_NAME" => $res["USER_START_NAME"], "~AUTHOR_NAME" => $res["~USER_START_NAME"], "AUTHOR_ID" => $res["USER_START_ID"], "~AUTHOR_ID" => $res["~USER_START_ID"], "~AUTHOR_LINK" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PROFILE_VIEW"], array("UID" => intVal($res["~USER_START_ID"]))), "AUTHOR_LINK" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("UID" => intVal($res["~USER_START_ID"]))), "~TOPIC_LINK" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_READ"], array("FID" => $res["FORUM_ID"], "TID" => $res["TOPIC_ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => "s")), "TOPIC_LINK" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_READ"], array("FID" => $res["FORUM_ID"], "TID" => $res["TOPIC_ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => "s")), "MESSAGES" => array());
 $topic["~AUTHOR_URL"] = "http://" . $arResult["SERVER_NAME"] . $topic["~AUTHOR_LINK"];
 $topic["AUTHOR_URL"] = "http://" . htmlspecialcharsEx($arResult["SERVER_NAME"]) . $topic["AUTHOR_LINK"];
 $topic["~URL"] = "http://" . $arResult["SERVER_NAME"] . $topic["~TOPIC_LINK"];
 $topic["URL"] = "http://" . htmlspecialcharsEx($arResult["SERVER_NAME"]) . $topic["TOPIC_LINK"];
 if (empty($arItems[$res["FORUM_ID"]]["TOPICS"][$res["TOPIC_ID"]])) {
     $arItems[$res["FORUM_ID"]]["TOPICS"][$res["TOPIC_ID"]] = $topic;
 }
 unset($res["TITLE"]);
 unset($res["DESCRIPTION"]);
Ejemplo n.º 25
0
$arHistSort[$by] = $order;
$arHistSort["ID"] = $order;

$arFilterHistory = array("ORDER_ID" => $ID);

if (strlen($filter_type)>0) $arFilterHistory["TYPE"] = trim($filter_type);
if (IntVal($filter_user)>0) $arFilterHistory["USER_ID"] = intval($filter_user);

if (strlen($filters_date_history_from)>0)
{
	$arFilterHistory["DATE_CREATE_FROM"] = Trim($filters_date_history_from);
}

if (strlen($filters_date_history_to)>0)
{
	if ($arDate = ParseDateTime($filters_date_history_to, CSite::GetDateFormat("FULL", SITE_ID)))
	{
		if (StrLen($filters_date_history_to) < 11)
		{
			$arDate["HH"] = 23;
			$arDate["MI"] = 59;
			$arDate["SS"] = 59;
		}

		$filters_date_history_to = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
		$arFilterHistory["DATE_CREATE_TO"] = $filters_date_history_to;
	}
	else
		$filters_date_history_to = "";
}
Ejemplo n.º 26
0
     $arParams["CURRENCY_BASE"] = COption::GetOptionString("sale", "default_currency");
 }
 if ('' == $arParams["CURRENCY_BASE"]) {
     $arParams["CURRENCY_BASE"] = CCurrency::GetBaseCurrency();
 }
 if ('' == $arParams["CURRENCY_BASE"]) {
     $dbCurrency = CCurrency::GetList($by = "SORT", $order = "ASC");
     $arCurrency = $dbCurrency->Fetch();
     $arParams["CURRENCY_BASE"] = $arCurrency["CURRENCY"];
 }
 if ('' != $arParams["CURRENCY_BASE"]) {
     if ('' == $arParams["RATE_DAY"]) {
         $arResult["RATE_DAY_TIMESTAMP"] = time();
         $arResult["RATE_DAY_SHOW"] = ConvertTimeStamp($arResult["RATE_DAY_TIMESTAMP"], 'SHORT');
     } else {
         $arRATE_DAY_PARSED = ParseDateTime($arParams["RATE_DAY"], "YYYY-MM-DD");
         $arRATE_DAY_PARSED['YYYY'] = intval($arRATE_DAY_PARSED['YYYY']);
         if (1901 > $arRATE_DAY_PARSED["YYYY"] || 2038 < $arRATE_DAY_PARSED["YYYY"]) {
             $arResult["RATE_DAY_TIMESTAMP"] = time();
             $arResult["RATE_DAY_SHOW"] = ConvertTimeStamp($arResult["RATE_DAY_TIMESTAMP"], 'SHORT');
         } else {
             $arResult["RATE_DAY_TIMESTAMP"] = mktime(0, 0, 0, $arRATE_DAY_PARSED["MM"], $arRATE_DAY_PARSED["DD"], $arRATE_DAY_PARSED["YYYY"]);
             $arResult["RATE_DAY_SHOW"] = ConvertTimeStamp($arResult["RATE_DAY_TIMESTAMP"], 'SHORT');
         }
     }
     if (!empty($arParams["arrCURRENCY_FROM"])) {
         if ('Y' == $arParams["SHOW_CB"]) {
             $bWarning = false;
             $obHttp = new CHTTP();
             $obHttp->Query('GET', 'www.cbr.ru', 80, "/scripts/XML_daily.asp?date_req=" . date("d.m.Y", $arResult["RATE_DAY_TIMESTAMP"]), false, '', 'N');
             $strQueryText = $obHttp->result;
Ejemplo n.º 27
0
     } elseif ($arEvents["EVENT_ID"] == "blog_post_micro") {
         if (!array_key_exists("microblog", $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arEvents["ENTITY_ID"], "blog", "view_post", $bCurrentUserIsAdmin)) {
             continue;
         }
     } elseif ($arEvents["EVENT_ID"] == "blog_comment") {
         if (!array_key_exists("blog", $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arEvents["ENTITY_ID"], "blog", "view_comment", $bCurrentUserIsAdmin)) {
             continue;
         }
     } else {
         if (!array_key_exists($arEvents["EVENT_ID"], $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arEvents["ENTITY_ID"], $arEvents["EVENT_ID"], $arSocNetFeaturesSettings[$arEvents["EVENT_ID"]]["minoperation"][0], $bCurrentUserIsAdmin)) {
             continue;
         }
     }
     $path2Entity = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arEvents["ENTITY_ID"]));
 }
 $arDateTmp = ParseDateTime($arEvents["LOG_DATE"], CSite::GetDateFormat('FULL'));
 $day = IntVal($arDateTmp["DD"]);
 $month = IntVal($arDateTmp["MM"]);
 $year = IntVal($arDateTmp["YYYY"]);
 $dateFormated = $day . ' ' . ToLower(GetMessage('MONTH_' . $month . '_S')) . ' ' . $year;
 $timeFormated = $arDateTmp["HH"] . ':' . $arDateTmp["MI"] . ':' . $arDateTmp["SS"];
 $arEvents["MESSAGE_FORMAT"] = htmlspecialcharsback($arEvents["MESSAGE"]);
 if (StrLen($arEvents["CALLBACK_FUNC"]) > 0) {
     if (StrLen($arEvents["MODULE_ID"]) > 0) {
         CModule::IncludeModule($arEvents["MODULE_ID"]);
     }
     $arEvents["MESSAGE_FORMAT"] = call_user_func($arEvents["CALLBACK_FUNC"], $arEvents);
 }
 if ($arEvents["EVENT_ID"] == "system" || $arEvents["EVENT_ID"] == "system_friends" || $arEvents["EVENT_ID"] == "system_groups") {
     $arEvents["TITLE_TEMPLATE"] = "";
     $arEvents["URL"] = "";
Ejemplo n.º 28
0
 function FormatDate($strDate, $format = "DD.MM.YYYY HH:MI:SS", $new_format = "DD.MM.YYYY HH:MI:SS")
 {
     $strDate = trim($strDate);
     $new_format = str_replace("MI", "I", strtoupper($new_format));
     $new_format = preg_replace("/([DMYIHGST])\\1+/is", "\\1", $new_format);
     $arParsedDate = ParseDateTime($strDate, $format);
     if (!$arParsedDate) {
         return false;
     }
     foreach ($arParsedDate as $k => $v) {
         if (preg_match("/[^0-9]/", $v)) {
             $arParsedDate[$k] = CDatabase::ForSql($v, 10);
         } else {
             $arParsedDate[$k] = intval($v);
         }
     }
     /*time hacks*/
     if (isset($arParsedDate["H"])) {
         $arParsedDate['HH'] = intval($arParsedDate["H"]);
         unset($arParsedDate["H"]);
     } elseif (isset($arParsedDate["GG"])) {
         $arParsedDate['HH'] = intval($arParsedDate["GG"]);
         unset($arParsedDate["GG"]);
     } elseif (isset($arParsedDate["G"])) {
         $arParsedDate['HH'] = intval($arParsedDate["G"]);
         unset($arParsedDate["G"]);
     }
     if (isset($arParsedDate['TT']) || isset($arParsedDate['T'])) {
         $middletime = $arParsedDate['TT'] ? $arParsedDate['TT'] : $arParsedDate['T'];
         if (strcasecmp($middletime, 'pm') === 0) {
             if ($arParsedDate['HH'] < 12) {
                 $arParsedDate['HH'] += 12;
             }
         } else {
             if ($arParsedDate['HH'] == 12) {
                 $arParsedDate['HH'] = 0;
             }
         }
         if (isset($arParsedDate['TT'])) {
             unset($arParsedDate['TT']);
         } else {
             unset($arParsedDate['T']);
         }
     }
     if (isset($arParsedDate["MMMM"])) {
         if (is_numeric($arParsedDate["MMMM"])) {
             $arParsedDate['MM'] = intval($arParsedDate["MMMM"]);
         } else {
             $arParsedDate['MM'] = GetNumMonth($arParsedDate["MMMM"]);
             if (!$arParsedDate['MM']) {
                 $arParsedDate['MM'] = intval(date('m', strtotime($arParsedDate["MMMM"])));
             }
         }
     } elseif (isset($arParsedDate["MM"])) {
         $arParsedDate['MM'] = intval($arParsedDate["MM"]);
     } elseif (isset($arParsedDate["M"])) {
         if (is_numeric($arParsedDate["M"])) {
             $arParsedDate['MM'] = intval($arParsedDate["M"]);
         } else {
             $arParsedDate['MM'] = GetNumMonth($arParsedDate["M"], true);
             if (!$arParsedDate['MM']) {
                 $arParsedDate['MM'] = intval(date('m', strtotime($arParsedDate["M"])));
             }
         }
     }
     if (isset($arParsedDate["YYYY"])) {
         $arParsedDate["YY"] = $arParsedDate["YYYY"];
     }
     if (intval($arParsedDate["DD"]) <= 0 || intval($arParsedDate["MM"]) <= 0 || intval($arParsedDate["YY"]) <= 0) {
         return false;
     }
     $strResult = "";
     if (intval($arParsedDate["YY"]) > 1970 && intval($arParsedDate["YY"]) < 2038) {
         $ux_time = mktime(isset($arParsedDate["HH"]) ? intval($arParsedDate["HH"]) : 0, isset($arParsedDate["MI"]) ? intval($arParsedDate["MI"]) : 0, isset($arParsedDate["SS"]) ? intval($arParsedDate["SS"]) : 0, intval($arParsedDate["MM"]), intval($arParsedDate["DD"]), intval($arParsedDate["YY"]));
         $new_format_len = strlen($new_format);
         for ($i = 0; $i < $new_format_len; $i++) {
             $ch = substr($new_format, $i, 1);
             if ($ch == "D") {
                 $strResult .= date("d", $ux_time);
             } elseif ($ch == "M") {
                 $strResult .= date("m", $ux_time);
             } elseif ($ch == "Y") {
                 $strResult .= date("Y", $ux_time);
             } elseif ($ch == "H") {
                 $strResult .= date("H", $ux_time);
             } elseif ($ch == "G") {
                 $strResult .= date("h", $ux_time);
             } elseif ($ch == "I") {
                 $strResult .= date("i", $ux_time);
             } elseif ($ch == "S") {
                 $strResult .= date("s", $ux_time);
             } elseif ($ch == "T") {
                 $strResult .= date("a", $ux_time);
             } else {
                 $strResult .= $ch;
             }
         }
     } else {
         if ($arParsedDate["MM"] < 1 || $arParsedDate["MM"] > 12) {
             $arParsedDate["MM"] = 1;
         }
         $new_format_len = strlen($new_format);
         for ($i = 0; $i < $new_format_len; $i++) {
             $ch = substr($new_format, $i, 1);
             if ($ch == "D") {
                 $strResult .= str_pad($arParsedDate["DD"], 2, "0", STR_PAD_LEFT);
             } elseif ($ch == "M") {
                 $strResult .= str_pad($arParsedDate["MM"], 2, "0", STR_PAD_LEFT);
             } elseif ($ch == "Y") {
                 $strResult .= str_pad($arParsedDate["YY"], 4, "0", STR_PAD_LEFT);
             } elseif ($ch == "H") {
                 $strResult .= str_pad($arParsedDate["HH"], 2, "0", STR_PAD_LEFT);
             } elseif ($ch == "I") {
                 $strResult .= str_pad($arParsedDate["MI"], 2, "0", STR_PAD_LEFT);
             } elseif ($ch == "S") {
                 $strResult .= str_pad($arParsedDate["SS"], 2, "0", STR_PAD_LEFT);
             } else {
                 $strResult .= $ch;
             }
         }
     }
     return $strResult;
 }
Ejemplo n.º 29
0
                 if (count($arNewDep) > 0) {
                     $dbRes = CIBlockSection::GetList(array('SORT' => 'ASC'), array('ID' => $arNewDep));
                     while ($arSect = $dbRes->Fetch()) {
                         $arDepCache[] = $arSect['ID'];
                         $arDepCacheValue[$arSect['ID']] = $arSect['NAME'];
                     }
                 }
                 foreach ($arUser['UF_DEPARTMENT'] as $key => $sect) {
                     $arDep[$sect] = $arDepCacheValue[$sect];
                 }
             }
             $arUser['UF_DEPARTMENT'] = $arDep;
             $arUser["DETAIL_URL"] = $arItem["URL"];
             $arUser['IS_ONLINE'] = $bSoNet && $arUser['IS_ONLINE'] == "Y";
             if ($arUser['PERSONAL_BIRTHDAY']) {
                 $arBirthDate = ParseDateTime($arUser['PERSONAL_BIRTHDAY'], CSite::GetDateFormat('SHORT'));
                 $arUser['IS_BIRTHDAY'] = intval($arBirthDate['MM']) == date('n') && intval($arBirthDate['DD']) == date('j');
             }
             $arUser['IS_FEATURED'] = CIntranetUtils::IsUserHonoured($arUser['ID']);
             $arUser['IS_ABSENT'] = CIntranetUtils::IsUserAbsent($arUser['ID']);
             $arResult["SEARCH"][$i]["USER"] = $arUser;
         }
     }
 }
 $arResult['USER_PROP'] = array();
 $arRes = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("USER", 0, LANGUAGE_ID);
 if (!empty($arRes)) {
     foreach ($arRes as $key => $val) {
         $arResult['USER_PROP'][$val["FIELD_NAME"]] = strLen($val["EDIT_FORM_LABEL"]) > 0 ? $val["EDIT_FORM_LABEL"] : $val["FIELD_NAME"];
     }
 }
Ejemplo n.º 30
0
            $arDate["SS"] = 59;
        }
        $find_last_order_date_2 = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
        $arFilter["<=LAST_ORDER_DATE"] = $find_last_order_date_2;
    } else {
        $find_last_order_date_2 = "";
    }
}
if (!empty($filter_register_date_1)) {
    $date1_stm = MkDateTime(FmtDate($filter_register_date_1, "D.M.Y"), "d.m.Y");
    if ($date1_stm && strlen(trim($filter_register_date_1)) > 0) {
        $arFilter[">=DATE_REGISTER"] = trim($filter_register_date_1);
    }
}
if (!empty($filter_register_date_2)) {
    if ($arDate = ParseDateTime($filter_register_date_2, CSite::GetDateFormat("FULL", SITE_ID))) {
        if (StrLen($filter_register_date_2) < 11) {
            $arDate["HH"] = 23;
            $arDate["MI"] = 59;
            $arDate["SS"] = 59;
        }
        $filter_register_date_2 = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
        $arFilter["<=DATE_REGISTER"] = $filter_register_date_2;
    } else {
        $filter_register_date_2 = "";
    }
}
if (isset($filter_group) && count($filter_group) > 0) {
    $arFilter["GROUPS_ID"] = $filter_group;
}
if (isset($filter_universal) && strlen($filter_universal) > 0) {