$arBlog = CBlog::GetByUrl($arParams["BLOG_URL"], $arParams["GROUP_ID"]); $arBlog = CBlogTools::htmlspecialcharsExArray($arBlog); } $arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]); $arResult["Blog"] = $arBlog; if ($bIDbyCode) { $arParams["ID"] = CBlogPost::GetID($arParams["ID"], $arBlog["ID"]); } $arPost = CBlogPost::GetByID($arParams["ID"]); if (empty($arPost) && !$bIDbyCode) { $arParams["ID"] = CBlogPost::GetID($arParams["ID"], $arBlog["ID"]); $arPost = CBlogPost::GetByID($arParams["ID"]); } if (!$bSoNet) { if (IntVal($arParams["ID"]) > 0) { $arResult["Perm"] = CBlogPost::GetBlogUserCommentPerms($arParams["ID"], $user_id); } else { $arResult["Perm"] = CBlog::GetBlogUserCommentPerms($arBlog["ID"], $user_id); } } if ((!empty($arPost) && ($arPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH || $arResult["IDEA_MODERATOR"]) && $arPost["ENABLE_COMMENTS"] == "Y" || $simpleComment) && ($arBlog["ACTIVE"] == "Y" && $arGroup["SITE_ID"] == SITE_ID || $simpleComment)) { $arPost = CBlogTools::htmlspecialcharsExArray($arPost); $arResult["Post"] = $arPost; if ($arPost["BLOG_ID"] == $arBlog["ID"] || $simpleComment) { //Comment delete if (IntVal($_GET["delete_comment_id"]) > 0 && $arResult["IDEA_MODERATOR"]) { if ($_GET["success"] == "Y") { $arResult["MESSAGE"] = GetMessage("B_B_PC_MES_DELED"); } else { $arComment = CBlogComment::GetByID(IntVal($_GET["delete_comment_id"])); if ($arResult["Perm"] >= BLOG_PERMS_MODERATE && !empty($arComment)) {
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."&"; 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("&", "<", ">", """), $title); */ //$text1 = HTMLToTxt($text, "", Array("\ "), 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; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } IncludeTemplateLangFile(__FILE__); /* $APPLICATION->IncludeFile("blog/blog/post_comment.php"); */ $is404 = $is404 == 'N' ? false : true; if (CModule::IncludeModule("blog")) { $GLOBALS["APPLICATION"]->SetTemplateCSS("blog/blog.css"); if (IntVal($_POST["postId"]) > 0 && IntVal($_POST["blogId"]) > 0) { $Perm = CBlogPost::GetBlogUserCommentPerms(IntVal($_POST["postId"]), $USER->GetID()); $message = null; $strErrorMessage = ""; $arr = CBlogSitePath::GetBySiteID(SITE_ID); $sBlogPath = $arr['PATH']; if ($Perm >= BLOG_PERMS_WRITE && $_POST["sessid"] == bitrix_sessid() && strlen($_POST["post"]) > 0) { //print_r($_POST); $strErrorMessage = ''; $arBlog = CBlog::GetByID(IntVal($_POST["blogId"])); $arPost = CBlogPost::GetByID(IntVal($_POST["postId"])); $APPLICATION->AddChainItem($arBlog["NAME"], CBlog::PreparePath($arBlog["URL"])); $APPLICATION->AddChainItem($arPost["TITLE"], CBlogPost::PreparePath($arBlog["URL"], $arPost["ID"])); if (!$USER->IsAuthorized() && $arBlog["ENABLE_IMG_VERIF"] == "Y") { include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/captcha.php"; $captcha_code = $_POST["captcha_code"]; $captcha_word = $_POST["captcha_word"]; $cpt = new CCaptcha(); $captchaPass = COption::GetOptionString("main", "captcha_password", "");