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; }
$lAdmin->AddHeaders($arHeaders); $arVisibleColumns = $lAdmin->GetVisibleHeaderColumns(); $arSelectedFields = array("ID", "NAME", "DATE_CREATE", "DATE_UPDATE", "ACTIVE", "OWNER_ID", "URL", "REAL_URL", "GROUP_ID", "OWNER_LOGIN", "OWNER_NAME", "OWNER_LAST_NAME", "OWNER_EMAIL", "GROUP_NAME", "GROUP_SITE_ID", "SOCNET_GROUP_ID", "USE_SOCNET"); foreach ($arVisibleColumns as $val) { if (!in_array($val, $arSelectedFields)) { $arSelectedFields[] = $val; } } $dbResultList = CBlog::GetList(array($by => $order), $arFilter, false, array("nPageSize" => CAdminResult::GetNavSize($sTableID)), $arSelectedFields); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("BLB_GROUP_NAV"))); while ($arBlog = $dbResultList->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arBlog, "/bitrix/admin/blog_blog_edit.php?ID=" . $f_ID . "&lang=" . LANGUAGE_ID, GetMessage("BLB_UPDATE_ALT")); $row->AddField("ID", '<a href="/bitrix/admin/blog_blog_edit.php?ID=' . $f_ID . '&lang=' . LANGUAGE_ID . '" title="' . GetMessage("BLB_UPDATE_ALT") . '">' . $f_ID . '</a>'); $row->AddField("NAME", "<a href=\"" . CBlog::PreparePath($f_URL, $f_GROUP_SITE_ID, false, $f_OWNER_ID, $f_SOCNET_GROUP_ID) . "\">" . $f_NAME . "</a>"); $row->AddField("DATE_CREATE", $f_DATE_CREATE); $row->AddField("DATE_UPDATE", $f_DATE_UPDATE); $row->AddField("ACTIVE", $f_ACTIVE == "Y" ? GetMessage("BLB_YES") : GetMessage("BLB_NO")); if (IntVal($f_OWNER_ID) > 0) { $row->AddField("OWNER_INFO", "<a href=\"/bitrix/admin/user_edit.php?ID=" . $f_OWNER_ID . "&lang=" . LANG . "\">[" . $f_OWNER_ID . "] " . $f_OWNER_NAME . " " . $f_OWNER_LAST_NAME . " (" . $f_OWNER_LOGIN . ")</a>"); } if (IntVal($f_SOCNET_GROUP_ID) > 0) { $row->AddField("SOCNET_GROUP_ID", $f_SOCNET_GROUP_ID); if (CModule::IncludeModule("socialnetwork")) { $arGroupSo = CSocNetGroup::GetByID($f_SOCNET_GROUP_ID); if (!empty($arGroupSo)) { $row->AddField("SOCNET_GROUP_ID", "[" . $f_SOCNET_GROUP_ID . "] " . $arGroupSo["NAME"]); } } }
function OnSearchReindex($NS = array(), $oCallback = NULL, $callback_method = "") { global $DB; $arResult = array(); //CBlogSearch::Trace('OnSearchReindex', 'NS', $NS); if ($NS["MODULE"] == "blog" && strlen($NS["ID"]) > 0) { $category = substr($NS["ID"], 0, 1); $id = intval(substr($NS["ID"], 1)); } else { $category = 'B'; //start with blogs $id = 0; //very first id } //CBlogSearch::Trace('OnSearchReindex', 'category+id', array("CATEGORY"=>$category,"ID"=>$id)); //Reindex blogs if ($category == 'B') { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tb.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("b.DATE_UPDATE") . " as DATE_UPDATE\n\t\t\t\t\t,b.NAME\n\t\t\t\t\t,b.DESCRIPTION\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\tFROM\n\t\t\t\t\tb_blog b\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tb.ACTIVE = 'Y'\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND b.ID > " . $id . "\n\t\t\t\tORDER BY\n\t\t\t\t\tb.ID\n\t\t\t"; //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql); $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($ar = $rs->Fetch()) { if ($ar["USE_SOCNET"] == "Y") { $Result = array("ID" => "B" . $ar["ID"], "BODY" => "", "TITLE" => ""); } else { //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar); $arSite = array($ar["SITE_ID"] => CBlog::PreparePath($ar["URL"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"])); //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite); $Result = array("ID" => "B" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_UPDATE"], "TITLE" => $ar["NAME"], "BODY" => blogTextParser::killAllTags($ar["DESCRIPTION"]), "SITE_ID" => $arSite, "PARAM1" => "BLOG", "PARAM2" => $ar["OWNER_ID"], "PERMISSIONS" => array(2)); //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result); } if ($oCallback) { $res = call_user_func(array($oCallback, $callback_method), $Result); if (!$res) { return $Result["ID"]; } } else { $arResult[] = $Result; } } //all blogs indexed so let's start index posts $category = 'P'; $id = 0; } if ($category == 'P') { $arUser2Blog = array(); if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") { $dbB = CBlog::GetList(array(), array("USE_SOCNET" => "Y", "!OWNER_ID" => false), false, false, array("ID", "OWNER_ID", "USE_SOCNET", "GROUP_ID")); while ($arB = $dbB->Fetch()) { $arUser2Blog[$arB["OWNER_ID"]][$arB["GROUP_ID"]] = $arB["ID"]; } } $bSonet = false; if (IsModuleInstalled("socialnetwork")) { $bSonet = true; } $parserBlog = new blogTextParser(false, "/bitrix/images/blog/smile/"); $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbp.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("bp.DATE_PUBLISH") . " as DATE_PUBLISH\n\t\t\t\t\t,bp.TITLE\n\t\t\t\t\t,bp.DETAIL_TEXT\n\t\t\t\t\t,bp.BLOG_ID\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,bp.CATEGORY_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\t\t,b.GROUP_ID\n\t\t\t\t\t,bp.PATH\n\t\t\t\t\t,bp.MICRO\n\t\t\t\t\t,bp.PUBLISH_STATUS\n\t\t\t\t\t,bp.AUTHOR_ID " . ($bSonet ? ", BSL.ID as SLID" : "") . " FROM\n\t\t\t\t\tb_blog_post bp\n\t\t\t\t\tINNER JOIN b_blog b ON (bp.BLOG_ID = b.ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID) " . ($bSonet ? "LEFT JOIN b_sonet_log BSL ON (BSL.EVENT_ID in ('blog_post', 'blog_post_micro') AND BSL.SOURCE_ID = bp.ID) " : "") . " WHERE\n\t\t\t\t\tbp.DATE_PUBLISH <= " . $DB->CurrentTimeFunction() . "\n\t\t\t\t\tAND b.ACTIVE = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND bp.ID > " . $id . "\n\t\t\t\t\t\n\t\t\t\tORDER BY\n\t\t\t\t\tbp.ID\n\t\t\t"; /* AND bp.PUBLISH_STATUS = '".$DB->ForSQL(BLOG_PUBLISH_STATUS_PUBLISH)."'*/ //AND b.SEARCH_INDEX = 'Y' //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql); $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($ar = $rs->Fetch()) { //Check permissions $tag = ""; if ($ar["USE_SOCNET"] != "Y") { $PostPerms = CBlogUserGroup::GetGroupPerms(1, $ar["BLOG_ID"], $ar["ID"], BLOG_PERMS_POST); if ($PostPerms < BLOG_PERMS_READ) { continue; } } //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar); if (strlen($ar["PATH"]) > 0) { $arSite = array($ar["SITE_ID"] => str_replace("#post_id#", $ar["ID"], $ar["PATH"])); } else { $arSite = array($ar["SITE_ID"] => CBlogPost::PreparePath($ar["URL"], $ar["ID"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"])); } if (strlen($ar["CATEGORY_ID"]) > 0) { $arC = explode(",", $ar["CATEGORY_ID"]); $tag = ""; $arTag = array(); foreach ($arC as $v) { $arCategory = CBlogCategory::GetByID($v); $arTag[] = $arCategory["NAME"]; } $tag = implode(",", $arTag); } //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite); $Result = array("ID" => "P" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_PUBLISH"], "TITLE" => blogTextParser::killAllTags($ar["TITLE"]), "BODY" => blogTextParser::killAllTags($ar["DETAIL_TEXT"]), "SITE_ID" => $arSite, "PARAM1" => "POST", "PARAM2" => $ar["BLOG_ID"], "PERMISSIONS" => array(2), "TAGS" => $tag, "USER_ID" => $ar["AUTHOR_ID"], "ENTITY_TYPE_ID" => "BLOG_POST", "ENTITY_ID" => $ar["ID"]); if ($ar["USE_SOCNET"] == "Y" && CModule::IncludeModule("socialnetwork")) { $arF = array(); if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") { if (IntVal($ar["SOCNET_GROUP_ID"]) > 0) { $newBlogId = 0; if (IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]) > 0) { $newBlogId = IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]); } else { $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => $ar["GROUP_ID"], "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P")); $bRights = false; $rsUser = CUser::GetByID($ar["AUTHOR_ID"]); $arUser = $rsUser->Fetch(); if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) { $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"]; } else { $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"]; } $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . $ar["SITE_ID"]; $arFields["OWNER_ID"] = $ar["AUTHOR_ID"]; $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]); if ($urlCheck != $arFields["URL"]) { $arFields["URL"] = "u" . $arUser["ID"] . "-blog-" . $ar["SITE_ID"]; } if (CBlog::GetByUrl($arFields["URL"])) { $uind = 0; do { $uind++; $arFields["URL"] = $arFields["URL"] . $uind; } while (CBlog::GetByUrl($arFields["URL"])); } $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ar["AUTHOR_ID"], "blog", "view_post"); if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) { $bRights = true; } $blogID = CBlog::Add($arFields); if ($bRights) { CBlog::AddSocnetRead($blogID); } $newBlogId = $blogID; $arUser2Blog[$arFields["OWNER_ID"]][$arFields["GROUP_ID"]] = $newBlogId; } if (intVal($newBlogId) > 0) { $arF = array("BLOG_ID" => $newBlogId, "SOCNET_RIGHTS" => array("SG" . $ar["SOCNET_GROUP_ID"])); } if (IntVal($ar["SLID"]) > 0) { CSocNetLog::Delete($ar["SLID"]); $ar["SLID"] = 0; } $arSites = array(); $rsGroupSite = CSocNetGroup::GetSite($ar["SOCNET_GROUP_ID"]); while ($arGroupSite = $rsGroupSite->Fetch()) { $arSites[] = $arGroupSite["LID"]; } } else { $newBlogId = 0; if ($ar["OWNER_ID"] != $ar["AUTHOR_ID"]) { if (IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]) > 0) { $newBlogId = IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]); } else { $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => $ar["GROUP_ID"], "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P")); $bRights = false; $rsUser = CUser::GetByID($ar["AUTHOR_ID"]); $arUser = $rsUser->Fetch(); if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) { $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"]; } else { $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"]; } $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . $ar["SITE_ID"]; $arFields["OWNER_ID"] = $ar["AUTHOR_ID"]; $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]); if ($urlCheck != $arFields["URL"]) { $arFields["URL"] = "u" . $arUser["ID"] . "-blog-" . $ar["SITE_ID"]; } if (CBlog::GetByUrl($arFields["URL"])) { $uind = 0; do { $uind++; $arFields["URL"] = $arFields["URL"] . $uind; } while (CBlog::GetByUrl($arFields["URL"])); } $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ar["AUTHOR_ID"], "blog", "view_post"); if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) { $bRights = true; } $blogID = CBlog::Add($arFields); if ($bRights) { CBlog::AddSocnetRead($blogID); } $newBlogId = $blogID; $arUser2Blog[$arFields["OWNER_ID"]][$arFields["GROUP_ID"]] = $newBlogId; } if (IntVal($ar["SLID"]) > 0) { CSocNetLog::Delete($ar["SLID"]); $ar["SLID"] = 0; } } $arF = array("SOCNET_RIGHTS" => array()); if (intVal($newBlogId) > 0) { $arF["BLOG_ID"] = $newBlogId; } $arSites = array($ar["SITE_ID"]); } if (!empty($arF)) { if (IntVal($arF["BLOG_ID"]) > 0) { $Result["PARAM2"] = $ar["BLOG_ID"]; $sqlR = "UPDATE b_blog_post SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE ID=" . IntVal($ar["ID"]); $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); $sqlR = "UPDATE b_blog_post_category SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]); $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); $sqlR = "UPDATE b_blog_image SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]); $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); $sqlR = "UPDATE b_blog_comment SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]); $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); } $sqlR = "SELECT * FROM b_blog_socnet_rights where POST_ID=" . IntVal($ar["ID"]); $dbBB = $DB->Query($sqlR); if (!$dbBB->Fetch()) { $arF["SC_PERM"] = CBlogPost::UpdateSocNetPerms($ar["ID"], $arF["SOCNET_RIGHTS"], array("AUTHOR_ID" => $ar["AUTHOR_ID"])); } if (IntVal($arF["BLOG_ID"]) > 0 && $ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) { $dbComment = CBlogComment::GetList(array(), array("POST_ID" => $ar["ID"]), false, false, array("ID", "POST_ID", "BLOG_ID", "PATH")); if ($arComment = $dbComment->Fetch()) { $arParamsComment = array("BLOG_ID" => $arF["BLOG_ID"], "POST_ID" => $ar["ID"], "SITE_ID" => $ar["SITE_ID"], "PATH" => $arPostSite[$arGroup["SITE_ID"]] . "?commentId=#comment_id###comment_id#", "USE_SOCNET" => "Y"); CBlogComment::_IndexPostComments($arParamsComment); } } } } if ($ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) { if (empty($arF["SC_PERM"])) { $arF["SC_PERM"] = CBlogPost::GetSocNetPermsCode($ar["ID"]); } $Result["PERMISSIONS"] = $arF["SC_PERM"]; if (IntVal($ar["SLID"]) <= 0) { $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "TABLE" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N"); $text4message = $parserBlog->convert($ar["DETAIL_TEXT"], false, array(), $arAllow, array("isSonetLog" => true)); $arSoFields = array("EVENT_ID" => "blog_post", "=LOG_DATE" => $DB->CharToDateFunction($ar["DATE_PUBLISH"], "FULL", SITE_ID), "LOG_UPDATE" => $DB->CharToDateFunction($ar["DATE_PUBLISH"], "FULL", SITE_ID), "TITLE_TEMPLATE" => "#USER_NAME# add post", "TITLE" => $ar["TITLE"], "MESSAGE" => $text4message, "MODULE_ID" => "blog", "CALLBACK_FUNC" => false, "SOURCE_ID" => $ar["ID"], "ENABLE_COMMENTS" => "N", "ENTITY_TYPE" => SONET_ENTITY_USER, "ENTITY_ID" => $ar["AUTHOR_ID"], "USER_ID" => $ar["AUTHOR_ID"], "URL" => $arSite[$ar["SITE_ID"]], "SITE_ID" => $arSites); $logID = CSocNetLog::Add($arSoFields, false); if (intval($logID) > 0) { $socnetPerms = $arF["SC_PERM"]; if (!in_array("U" . $ar["AUTHOR_ID"], $socnetPerms)) { $socnetPerms[] = "U" . $ar["AUTHOR_ID"]; } $socnetPerms[] = "SA"; // socnet admin CSocNetLog::Update($logID, array("TMP_ID" => $logID, "=LOG_UPDATE" => $arSoFields["LOG_UPDATE"])); CSocNetLogRights::DeleteByLogID($logID); CSocNetLogRights::Add($logID, $socnetPerms); } } else { $socnetPerms = $arF["SC_PERM"]; if (!in_array("U" . $ar["AUTHOR_ID"], $socnetPerms)) { $socnetPerms[] = "U" . $ar["AUTHOR_ID"]; } $socnetPerms[] = "SA"; // socnet admin CSocNetLogRights::DeleteByLogID($ar["SLID"]); CSocNetLogRights::Add($ar["SLID"], $socnetPerms); } } } if ($ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $ar["SEARCH_INDEX"] == "Y") { //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result); if ($oCallback) { $res = call_user_func(array($oCallback, $callback_method), $Result); if (!$res) { return $Result["ID"]; } } else { $arResult[] = $Result; } } } //all blog posts indexed so let's start index users $category = 'C'; $id = 0; COption::SetOptionString("blog", "socNetNewPerms", "Y"); } if ($category == 'C') { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbc.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,bp.ID as POST_ID\n\t\t\t\t\t,b.URL\n\t\t\t\t\t,bp.TITLE as POST_TITLE\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,bc.TITLE\n\t\t\t\t\t,bc.POST_TEXT\n\t\t\t\t\t,bc.POST_ID\n\t\t\t\t\t,bc.BLOG_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\t\t,bc.PATH\n\t\t\t\t\t," . $DB->DateToCharFunction("bc.DATE_CREATE") . " as DATE_CREATE\n\t\t\t\t\t,bc.AUTHOR_ID\n\t\t\t\tFROM\n\t\t\t\t\tb_blog_comment bc\n\t\t\t\t\tINNER JOIN b_blog_post bp ON (bp.ID = bc.POST_ID)\n\t\t\t\t\tINNER JOIN b_blog b ON (bc.BLOG_ID = b.ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tbc.ID > " . $id . " \n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? " AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\tORDER BY\n\t\t\t\t\tbc.ID\n\t\t\t"; //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql); $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($ar = $rs->Fetch()) { //Check permissions $tag = ""; $PostPerms = CBlogUserGroup::GetGroupPerms(1, $ar["BLOG_ID"], $ar["POST_ID"], BLOG_PERMS_POST); if ($PostPerms < BLOG_PERMS_READ) { continue; } //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar); if (strlen($ar["PATH"]) > 0) { $arSite = array($ar["SITE_ID"] => str_replace("#comment_id#", $ar["ID"], $ar["PATH"])); } else { $arSite = array($ar["SITE_ID"] => CBlogPost::PreparePath($ar["URL"], $ar["POST_ID"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"])); } $Result = array("ID" => "C" . $ar["ID"], "SITE_ID" => $arSite, "LAST_MODIFIED" => $ar["DATE_CREATE"], "PARAM1" => "COMMENT", "PARAM2" => $ar["BLOG_ID"] . "|" . $ar["POST_ID"], "PERMISSIONS" => array(2), "TITLE" => $ar["TITLE"], "BODY" => blogTextParser::killAllTags($ar["POST_TEXT"]), "INDEX_TITLE" => false, "USER_ID" => IntVal($ar["AUTHOR_ID"]) > 0 ? $ar["AUTHOR_ID"] : false, "ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $ar["ID"]); if ($ar["USE_SOCNET"] == "Y") { $arSp = CBlogComment::GetSocNetCommentPerms($ar["POST_ID"]); if (is_array($arSp)) { $Result["PERMISSIONS"] = $arSp; } } if (strlen($ar["TITLE"]) <= 0) { $Result["TITLE"] = substr($Result["BODY"], 0, 100); } if ($oCallback) { $res = call_user_func(array($oCallback, $callback_method), $Result); if (!$res) { return $Result["ID"]; } } else { $arResult[] = $Result; } } //all blog posts indexed so let's start index users $category = 'U'; $id = 0; } if ($category == 'U') { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbu.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t," . $DB->DateToCharFunction("bu.LAST_VISIT") . " as LAST_VISIT\n\t\t\t\t\t," . $DB->DateToCharFunction("u.DATE_REGISTER") . " as DATE_REGISTER\n\t\t\t\t\t,bu.ALIAS\n\t\t\t\t\t,bu.DESCRIPTION\n\t\t\t\t\t,bu.INTERESTS\n\t\t\t\t\t,u.NAME\n\t\t\t\t\t,u.LAST_NAME\n\t\t\t\t\t,u.LOGIN\n\t\t\t\t\t,bu.USER_ID\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\tFROM\n\t\t\t\t\tb_blog_user bu\n\t\t\t\t\tINNER JOIN b_user u ON (u.ID = bu.USER_ID)\n\t\t\t\t\tINNER JOIN b_blog b ON (u.ID = b.OWNER_ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tb.ACTIVE = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND bu.ID > " . $id . "\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\tORDER BY\n\t\t\t\t\tbu.ID\n\t\t\t"; //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql); $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($ar = $rs->Fetch()) { if ($ar["USE_SOCNET"] == "Y") { $Result = array("ID" => "U" . $ar["ID"], "BODY" => "", "TITLE" => ""); } else { //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar); $arSite = array($ar["SITE_ID"] => CBlogUser::PreparePath($ar["USER_ID"], $ar["SITE_ID"])); //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite); $Result = array("ID" => "U" . $ar["ID"], "LAST_MODIFIED" => $ar["LAST_VISIT"], "TITLE" => CBlogUser::GetUserName($ar["ALIAS"], $ar["NAME"], $ar["LAST_NAME"], $ar["LOGIN"]), "BODY" => blogTextParser::killAllTags($ar["DESCRIPTION"] . " " . $ar["INTERESTS"]), "SITE_ID" => $arSite, "PARAM1" => "USER", "PARAM2" => $ar["ID"], "PERMISSIONS" => array(2)); if (strlen($Result["LAST_MODIFIED"]) <= 0) { $Result["LAST_MODIFIED"] = $ar["DATE_REGISTER"]; } } //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result); if ($oCallback) { $res = call_user_func(array($oCallback, $callback_method), $Result); if (!$res) { return $Result["ID"]; } } else { $arResult[] = $Result; } } } if ($oCallback) { return false; } return $arResult; }
$APPLICATION->SetTitle($arGroup["NAME"]); //формируем кэш $cache = new CPHPCache(); $cache_id = "blog_groups_" . serialize($arParams) . "_" . CDBResult::NavStringForCache($BLOGS_COUNT); $cache_path = "/" . SITE_ID . "/blog/groups/" . $ID . "/"; if ($CACHE_TIME > 0 && $cache->InitCache($CACHE_TIME, $cache_id, $cache_path)) { $cache->Output(); } else { if ($CACHE_TIME > 0) { $cache->StartDataCache($CACHE_TIME, $cache_id, $cache_path); } $dbBlogs = CBlog::GetList($SORT, $arFilter, false, $COUNT, $arSelectFields); if ($arBlogs = $dbBlogs->NavNext(false)) { //$dbBlogs->NavPrint(GetMessage("B_B_GR_TITLE")); do { $urlToBlog = CBlog::PreparePath($arBlogs["URL"], SITE_ID, $is404); $urlToPost = CBlogPost::PreparePath($arBlogs["URL"], $arBlogs["LAST_POST_ID"], SITE_ID, $is404); $urlToAuthor = CBlogUser::PreparePath($arBlogs["OWNER_ID"], SITE_ID, $is404); $AuthorName = CBlogUser::GetUserName($arBlogs["BLOG_USER_ALIAS"], $arBlogs["OWNER_NAME"], $arBlogs["OWNER_LAST_NAME"], $arBlogs["OWNER_LOGIN"]); ?> <table class="blogtableborder" cellspacing="1" cellpadding="0" width="100%" border="0"> <tr> <td> <table border="0" width="100%" cellpadding="3" cellspacing="0" class="blogtablebody"> <tr> <td class="blogtablehead" align="left" nowrap width="70%" style="padding-left:10px;"><font class="blogpostdate"><a href="<?php echo $urlToBlog; ?> "><?php echo htmlspecialcharsex($arBlogs["NAME"]); ?>
BXClearCache(True, "/" . SITE_ID . "/blog/new_blogs/"); BXClearCache(True, "/" . SITE_ID . "/blog/groups/" . $arBlog['GROUP_ID'] . "/"); BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog['URL']); CBlogUserGroup::Add(array("BLOG_ID" => $newID, "NAME" => GetMessage('BLOG_FRIENDS'))); } } if ($newID && !$errorMessage) { $arBlog = CBlog::GetByID($newID); if ($_POST['apply']) { if ($is404) { LocalRedirect(CBlog::PreparePath($arBlog['URL'], false, $is404) . "blog_edit.php"); } else { $page = $arSitePath["PATH"] . "/blog_edit.php?blog=" . htmlspecialchars($arBlog['URL']); } } else { LocalRedirect(CBlog::PreparePath($arBlog['URL'], false, $is404)); } } else { $bVarsFromForm = true; if ($ex = $APPLICATION->GetException()) { $errorMessage .= $ex->GetString() . ".<br>"; } else { $errorMessage .= GetMessage('BLOG_ERR_SAVE') . ".<br>"; } } } if ($arBlog) { $APPLICATION->SetTitle(str_replace("#BLOG#", htmlspecialchars($arBlog["NAME"]), GetMessage('BLOG_TOP_TITLE'))); } else { $APPLICATION->SetTitle(GetMessage('BLOG_NEW_BLOG')); }
function Update($ID, $arFields) { global $DB; $ID = IntVal($ID); if ($ID <= 0) { return false; } if (strlen($arFields["PATH"]) > 0) { $path = $arFields["PATH"]; unset($arFields["PATH"]); } $arFields1 = array(); foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "=") { $arFields1[substr($key, 1)] = $value; unset($arFields[$key]); } } if (!CBlog::CheckFields("UPDATE", $arFields, $ID)) { return false; } elseif (!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("BLOG_BLOG", $ID, $arFields)) { return false; } $db_events = GetModuleEvents("blog", "OnBeforeBlogUpdate"); while ($arEvent = $db_events->Fetch()) { if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) { return false; } } $arBlogOld = CBlog::GetByID($ID); $strUpdate = $DB->PrepareUpdate("b_blog", $arFields); foreach ($arFields1 as $key => $value) { if (strlen($strUpdate) > 0) { $strUpdate .= ", "; } $strUpdate .= $key . "=" . $value . " "; } if (strlen($strUpdate) > 0) { $strSql = "UPDATE b_blog SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " "; $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); unset($GLOBALS["BLOG"]["BLOG_CACHE_" . $ID]); unset($GLOBALS["BLOG"]["BLOG4OWNER_CACHE_" . $arBlogOld["OWNER_ID"]]); unset($GLOBALS["BLOG"]["BLOG4OWNERGROUP_CACHE_" . $arBlogOld["SOCNET_GROUP_ID"]]); $events = GetModuleEvents("blog", "OnBlogUpdate"); while ($arEvent = $events->Fetch()) { ExecuteModuleEventEx($arEvent, array($ID, &$arFields)); } if (is_set($arFields, "PERMS_POST")) { CBlog::SetBlogPerms($ID, $arFields["PERMS_POST"], BLOG_PERMS_POST); } if (is_set($arFields, "PERMS_COMMENT")) { CBlog::SetBlogPerms($ID, $arFields["PERMS_COMMENT"], BLOG_PERMS_COMMENT); } $GLOBALS["USER_FIELD_MANAGER"]->Update("BLOG_BLOG", $ID, $arFields); } else { $ID = False; } if ($ID && (is_set($arFields, "NAME") || is_set($arFields, "DESCRIPTION"))) { if (CModule::IncludeModule("search")) { $arBlog = CBlog::GetByID($ID); if ($arBlogOld["ACTIVE"] == "Y" && $arBlog["ACTIVE"] != "Y" || $arBlogOld["SEARCH_INDEX"] == "Y" && $arBlog["SEARCH_INDEX"] != "Y") { CSearch::DeleteIndex("blog", false, "COMMENT", $ID . "|%"); CSearch::DeleteIndex("blog", false, "POST", $ID); CSearch::DeleteIndex("blog", "B" . $ID); } elseif ($arBlog["ACTIVE"] == "Y" && $arBlog["SEARCH_INDEX"] == "Y") { if ($arBlog["USE_SOCNET"] == "Y") { CSearch::DeleteIndex("blog", "B" . $ID); } else { $arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]); if (strlen($path) > 0) { $path = str_replace("#blog_url#", $arBlog["URL"], $path); $arPostSite = array($arGroup["SITE_ID"] => $path); } else { $arPostSite = array($arGroup["SITE_ID"] => CBlog::PreparePath($arBlog["URL"], $arGroup["SITE_ID"], false, $arBlog["OWNER_ID"], $arBlog["SOCNET_GROUP_ID"])); } $arSearchIndex = array("SITE_ID" => $arPostSite, "LAST_MODIFIED" => $arBlog["DATE_UPDATE"], "PARAM1" => "BLOG", "PARAM2" => $arBlog["OWNER_ID"], "PERMISSIONS" => array(2), "TITLE" => $arBlog["NAME"], "BODY" => strlen($arBlog["DESCRIPTION"]) > 0 ? $arBlog["DESCRIPTION"] : $arBlog["NAME"]); CSearch::Index("blog", "B" . $ID, $arSearchIndex); } } } } return $ID; }
} else { if ($CACHE_TIME > 0) { $cache->StartDataCache($CACHE_TIME, $cache_id, $cache_path); } $dbCategory = CBlogCategory::GetList(array("NAME" => "ASC"), array("BLOG_ID" => $arBlog["ID"])); if ($arCategory = $dbCategory->Fetch()) { echo '<p align="left"><font class="blogtext">'; echo '<b>' . GetMessage("BLOG_BLOG_BLOGINFO_CAT") . '</b><br>'; do { if ($category == $arCategory["ID"]) { echo "<b>"; } if ($is404) { echo '<a href="' . CBlog::PreparePath($arBlog["URL"]) . '?category=' . $arCategory["ID"] . '" title="' . GetMessage("BLOG_BLOG_BLOGINFO_CAT_VIEW") . '">'; } else { echo '<a href="' . CBlog::PreparePath($arBlog["URL"], SITE_ID, $is404) . '&category=' . $arCategory["ID"] . '" title="' . GetMessage("BLOG_BLOG_BLOGINFO_CAT_VIEW") . '">'; } echo htmlspecialcharsex($arCategory["NAME"]); echo '</a>'; if ($category == $arCategory["ID"]) { echo "</b>"; } echo "<br>"; } while ($arCategory = $dbCategory->Fetch()); echo '</font><p>'; } if ($CACHE_TIME > 0) { $cache->EndDataCache(array()); } } echo '</div>';
<a href="<?php echo $urlToAuthor; ?> "><img src="/bitrix/templates/.default/blog/images/icon_user.gif" width="16" height="16" border="0" align="absmiddle"></a> <a href="<?php echo $urlToBlog; ?> "><?php echo htmlspecialcharsex($AuthorName); ?> </a></font></td> <?php if ($PostPerm >= BLOG_PERMS_MODERATE) { ?> <?php if ($is404) { $urlToEdit = CBlog::PreparePath($BLOG_URL) . $editPage . "?ID=" . $CurPost["ID"]; } else { $urlToEdit = $editPage . "?blog=" . htmlspecialcharsex($arBlog["URL"]) . "&post_id=" . $CurPost["ID"]; } ?> <td align="right" nowrap class="blogtablehead" valign="center" width="10%" style="padding-right:5px;"> <a href="<?php echo $urlToEdit; ?> "><img src="/bitrix/templates/.default/blog/images/edit_button.gif" width="18" height="18" border="0" title="<?php echo GetMessage("BLOG_BLOG_BLOG_EDIT_MES"); ?> "></a><img src="/bitrix/images/1.gif" width="5" height="1" border="0"><a href="javascript:if(confirm('<?php echo GetMessage("BLOG_MES_DELETE_POST_CONFIRM"); ?> ')) window.location='<?php
"RSS1" => "Y", "RSS2" => "Y", "ATOM" => "Y" ) ); */ $VERTICAL = $VERTICAL == "Y" ? true : false; $RSS1 = $RSS1 == "Y" ? true : false; $RSS2 = $RSS2 == "Y" ? true : false; $ATOM = $ATOM == "Y" ? true : false; $BLOG_URL = trim($BLOG_URL); $is404 = $is404 == 'N' ? false : true; if (CModule::IncludeModule("blog")) { $dbBlog = CBlog::GetList(array(), array("URL" => $BLOG_URL), false, array("nTopCount" => 1), $arSelectedFields); if ($arBlog = $dbBlog->Fetch()) { $url = CBlog::PreparePath($arBlog["URL"], SITE_ID, $is404); $sitePath = CBlogSitePath::GetBySiteID(SITE_ID); if ($is404) { if ($RSS1) { $arExport["RSS1"] = '<a href="' . $url . 'rss/rss1" title="RSS 0.92"><img src="/bitrix/templates/.default/blog/images/RSS1.gif" width="80" height="15" border="0"></a>'; } if ($RSS2) { $arExport["RSS2"] = '<a href="' . $url . 'rss/rss2" title="RSS 2.0"><img src="/bitrix/templates/.default/blog/images/RSS2.gif" width="80" height="15" border="0"></a>'; } if ($ATOM) { $arExport["ATOM"] = '<a href="' . $url . 'rss/atom" title="Atom 0.3"><img src="/bitrix/templates/.default/blog/images/ATOM.gif" width="80" height="15" border="0"></a>'; } } else { if ($RSS1) { $arExport["RSS1"] = '<a href="' . $sitePath["PATH"] . '/rss.php?blog=' . $BLOG_URL . '&type=rss1" title="RSS 0.92"><img src="/bitrix/templates/.default/blog/images/RSS1.gif" width="80" height="15" border="0"></a>'; }
echo $urtToBlog; ?> "><?php echo htmlspecialcharsex($AuthorName); ?> </a></font></td> <?php if ($PostPerm >= BLOG_PERMS_MODERATE) { ?> <?php if ($is404) { $urlToEdit = CBlog::PreparePath($arBlog["URL"]) . $editPage . "?ID=" . $arPost["ID"]; $pathToDel = CBlog::PreparePath($arBlog["URL"], false, $is404) . "?"; } else { $urlToEdit = $editPage . "?blog=" . htmlspecialcharsex($arBlog["URL"]) . "&post_id=" . $arPost["ID"]; $pathToDel = CBlog::PreparePath($arBlog["URL"], false, $is404) . "&"; } ?> <td align="right" nowrap class="blogtablehead" valign="center" style="padding-right:10px;"> <a href="<?php echo $urlToEdit; ?> "><img src="/bitrix/templates/.default/blog/images/edit_button.gif" width="18" height="18" border="0" title="<?php echo GetMessage("BLOG_BLOG_BLOG_EDIT_MES"); ?> "></a><img src="/bitrix/images/1.gif" width="5" height="1" border="0"><a href="javascript:if(confirm('<?php echo GetMessage("BLOG_MES_DELETE_POST_CONFIRM"); ?> ')) window.location='<?php echo $pathToDel; ?>
function BuildRSS($ID, $type = "RSS .92", $numPosts = 10, $blogTemplate = "", $postTemplate = "", $userTemplate = "", $bSoNet = false, $arParams = array()) { $ID = IntVal($ID); if ($ID <= 0 && $arParams["USE_SOCNET"] != "Y") { return false; } $numPosts = IntVal($numPosts); $type = strtolower(preg_replace("/[^a-zA-Z0-9.]/is", "", $type)); if ($type != "rss2.0" && $type != "atom.03") { $type = "rss.92"; } $rssText = False; $arBlog = CBlog::GetByID($ID); if ($arBlog && $arBlog["ACTIVE"] == "Y" && $arBlog["ENABLE_RSS"] == "Y" || $arParams["USE_SOCNET"] == "Y") { if (!empty($arBlog)) { $arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]); } if ($arGroup["SITE_ID"] == SITE_ID || $arParams["USE_SOCNET"] == "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 ($bSoNet) { if (IntVal($arParams["USER_ID"]) > 0) { $dbUser = CUser::GetByID($arParams["USER_ID"]); if ($arUser = $dbUser->Fetch()) { $blogName = htmlspecialcharsbx(GetMessage("BLG_RSS_NAME_SONET", array("#AUTHOR_NAME#" => CUser::FormatName(CSite::GetNameFormat(false), $arUser, true)))); $blogURL = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($blogTemplate, array("user_id" => $arParams["USER_ID"]))); } } else { if ($arGroupSoNet = CSocNetGroup::GetByID($arParams["SOCNET_GROUP_ID"])) { $blogName = htmlspecialcharsbx(GetMessage("BLG_RSS_NAME_SONET_GROUP", array("#GROUP_NAME#" => $arGroupSoNet["NAME"]))); $blogURL = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($blogTemplate, array("group_id" => $arParams["SOCNET_GROUP_ID"]))); } } $blogDescr = ""; } else { if (strlen($blogTemplate) > 0) { $blogURL = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($blogTemplate, 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"])); } $blogName = htmlspecialcharsbx($arBlog["NAME"]); $blogDescr = htmlspecialcharsbx($arBlog["DESCRIPTION"]); } $rssText = ""; if ($type == "rss.92") { $rssText .= "<" . "?xml version=\"1.0\" encoding=\"" . $charset . "\"?" . ">\n\n"; $rssText .= "<rss version=\".92\">\n"; $rssText .= " <channel>\n"; $rssText .= "\t<title>" . $blogName . "</title>\n"; $rssText .= "\t<link>" . $blogURL . "</link>\n"; $rssText .= "\t<description>" . $blogDescr . "</description>\n"; $rssText .= "\t<language>" . $language . "</language>\n"; $rssText .= "\t<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 .= "\t<title>" . $blogName . "</title>\n"; //$rssText .= " <guid>".$blogURL."</guid>\n"; $rssText .= "\t<link>" . $blogURL . "</link>\n"; $rssText .= "\t<description>" . $blogDescr . "</description>\n"; $rssText .= "\t<language>" . $language . "</language>\n"; $rssText .= "\t<docs>http://backend.userland.com/rss2</docs>\n"; $rssText .= "\t<pubDate>" . $now . "</pubDate>\n"; $rssText .= "\n"; } elseif ($type == "atom.03") { $atomID = "tag:" . htmlspecialcharsbx($serverName) . "," . date("Y-m-d") . ":" . $ID; $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>" . $blogURL . "</tagline>\n"; //$rssText .= " <link href=\"".$blogURL."\"/>"; $rssText .= " <id>" . $atomID . "</id>\n"; $rssText .= " <link rel=\"alternate\" type=\"text/html\" href=\"" . $blogURL . "\" />\n"; $rssText .= " <copyright>Copyright (c) " . $blogURL . "</copyright>\n"; $rssText .= " <modified>" . $nowISO . "</modified>\n"; $rssText .= "\n"; } $user_id = IntVal($GLOBALS["USER"]->GetID()); if ($bSoNet) { $postPerm = BLOG_PERMS_DENY; if (IntVal($arParams["SOCNET_GROUP_ID"]) > 0) { if (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "view_post")) { $postPerm = BLOG_PERMS_READ; } if (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "write_post")) { $postPerm = BLOG_PERMS_WRITE; } if (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "full_post", CSocNetUser::IsCurrentUserModuleAdmin()) || $GLOBALS["APPLICATION"]->GetGroupRight("blog") >= "W") { $postPerm = BLOG_PERMS_FULL; } } else { if ($user_id == $arParams["USER_ID"]) { $postPerm = BLOG_PERMS_FULL; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_USER, $arParams["USER_ID"], "blog", "view_post")) { $postPerm = BLOG_PERMS_READ; } } } else { $postPerm = CBlog::GetBlogUserPostPerms($ID, IntVal($user_id)); } if ($postPerm >= BLOG_PERMS_READ) { $parser = new blogTextParser(); $arParserParams = array("imageWidth" => $arParams["IMAGE_MAX_WIDTH"], "imageHeight" => $arParams["IMAGE_MAX_HEIGHT"]); if ($bSoNet) { $arFilter = array("<=DATE_PUBLISH" => ConvertTimeStamp(false, "FULL", false), "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "BLOG_ACTIVE" => "Y", "BLOG_GROUP_SITE_ID" => SITE_ID); if (IntVal($arParams["SOCNET_GROUP_ID"]) > 0) { $arFilter["SOCNET_GROUP_ID"] = $arParams["SOCNET_GROUP_ID"]; } else { $arFilter["FOR_USER"] = $user_id; $arFilter["AUTHOR_ID"] = $arParams["USER_ID"]; } } else { $arFilter = array("BLOG_ID" => $ID, "<=DATE_PUBLISH" => ConvertTimeStamp(false, "FULL", false), "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "MICRO" => "N"); } CTimeZone::Disable(); $dbPosts = CBlogPost::GetList(array("DATE_PUBLISH" => "DESC"), $arFilter, false, array("nTopCount" => $numPosts), array("ID", "TITLE", "DETAIL_TEXT", "DATE_PUBLISH", "AUTHOR_ID", "AUTHOR_NAME", "AUTHOR_LAST_NAME", "BLOG_USER_ALIAS", "DETAIL_TEXT_TYPE", "CODE", "PATH")); CTimeZone::Enable(); while ($arPost = $dbPosts->Fetch()) { if (!$bSoNet) { $perms = CBlogPost::GetBlogUserPostPerms($arPost["ID"], $GLOBALS["USER"]->IsAuthorized() ? $GLOBALS["USER"]->GetID() : 0); if ($perms < BLOG_PERMS_READ) { continue; } } //$title = htmlspecialcharsEx($arPost["TITLE"]); $title = str_replace(array("&", "<", ">", "\""), array("&", "<", ">", """), $arPost["TITLE"]); $res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost['ID'], "BLOG_ID" => $ID, "IS_COMMENT" => "N")); while ($arImage = $res->Fetch()) { $arImages[$arImage['ID']] = $arImage['FILE_ID']; } $arDate = ParseDateTime($arPost["DATE_PUBLISH"], CSite::GetDateFormat("FULL", $arGroup["SITE_ID"])); $date = date("r", mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"])); if (strlen($arPost["PATH"]) > 0) { $url = htmlspecialcharsbx("http://" . $serverName . str_replace("#post_id#", CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]), $arPost["PATH"])); } elseif (strLen($postTemplate) > 0) { $url = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($postTemplate, array("blog" => $arBlog["URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]), "user_id" => IntVal($arParams["USER_ID"]) > 0 ? $arParams["USER_ID"] : $arBlog["OWNER_ID"], "group_id" => IntVal($arParams["SOCNET_GROUP_ID"]) > 0 ? $arParams["SOCNET_GROUP_ID"] : $arBlog["SOCNET_GROUP_ID"]))); } else { $url = htmlspecialcharsbx("http://" . $serverName . CBlogPost::PreparePath($arBlog["URL"], $arPost["ID"], $arGroup["SITE_ID"])); } $category = htmlspecialcharsbx($arPost["CATEGORY_NAME"]); $BlogUser = CBlogUser::GetByID($arPost["AUTHOR_ID"], BLOG_BY_USER_ID); $dbUser = CUser::GetByID($arPost["AUTHOR_ID"]); $arUser = $dbUser->Fetch(); $author = htmlspecialcharsex(CBlogUser::GetUserName($BlogUser["ALIAS"], $arUser["NAME"], $arUser["LAST_NAME"], $arUser["LOGIN"], $arUser["SECOND_NAME"])); if (strLen($userTemplate) > 0) { $authorURL = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($userTemplate, array("user_id" => $arPost["AUTHOR_ID"]))); } else { $authorURL = htmlspecialcharsbx("http://" . $serverName . CBlogUser::PreparePath($arPost["AUTHOR_ID"], $arGroup["SITE_ID"])); } if ($arPost["DETAIL_TEXT_TYPE"] == "html") { $text = $parser->convert_to_rss($arPost["DETAIL_TEXT"], $arImages, array("HTML" => "Y", "ANCHOR" => "Y", "IMG" => "Y", "SMILES" => "Y", "NL2BR" => "N", "QUOTE" => "Y", "CODE" => "Y"), true, $arParserParams); } else { $text = $parser->convert_to_rss($arPost["DETAIL_TEXT"], $arImages, false, !$bSoNet, $arParserParams); } if (!$bSoNet) { $text .= "<br /><a href=\"" . $url . "\">" . GetMessage("BLG_GB_RSS_DETAIL") . "</a>"; } $text = "<![CDATA[" . $text . "]]>"; if ($type == "rss.92") { $rssText .= " <item>\n"; $rssText .= " <title>" . $title . "</title>\n"; $rssText .= " <description>" . $text . "</description>\n"; $rssText .= " <link>" . $url . "</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>" . $url . "</link>\n"; $rssText .= " <guid>" . $url . "</guid>\n"; $rssText .= " <pubDate>" . $date . "</pubDate>\n"; if (strlen($category) > 0) { $rssText .= " <category>" . $category . "</category>\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); $titleRel = htmlspecialcharsbx($arPost["TITLE"]); $rssText .= "<entry>\n"; $rssText .= " <title type=\"text/html\">" . $title . "</title>\n"; $rssText .= " <link rel=\"alternate\" type=\"text/html\" href=\"" . $url . "\"/>\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 .= " <link rel=\"related\" type=\"text/html\" href=\"" . $url . "\" title=\"" . $titleRel . "\"/>\n"; $rssText .= " <author>\n"; $rssText .= " <name>" . $author . "</name>\n"; $rssText .= " <url>" . $authorURL . "</url>\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; }
$errorMessage .= str_replace("#NAME#", $friend, GetMessage("BLOG_BLOG_ADD_F_POS_NOT_FOUND")) . ".<br>"; } } } } $sessKey = randString(10); $_SESSION[$sessKey] = array(); $_SESSION[$sessKey]["ERROR"] = $errorMessage; $_SESSION[$sessKey]["OK"] = $okMessage; if ($is404) { LocalRedirect(CBlog::PreparePath($BLOG_URL) . "user_settings.php?sessKey=" . UrlEncode($sessKey)); } else { LocalRedirect($strPath . "/user_settings.php?sessKey=" . UrlEncode($sessKey) . "&blog=" . $BLOG_URL); } } else { LocalRedirect($strPath . "/blog_auth.php?back_url=" . UrlEncode(CBlog::PreparePath($BLOG_URL) . "user_settings.php")); ?> <div class="blogError"><?php echo GetMessage("BLOG_BLOG_ADD_F_U_HAVENT_RIGHTS"); ?> </div><?php } } else { ?> <div class="blogError"><?php echo GetMessage("BLOG_BLOG_ADD_F_BLOG_NOT_FOUND"); ?> </div><?php } } else { ?>
*/ $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", ""); if (strlen($captcha_code) > 0) { if (!$cpt->CheckCodeCrypt($captcha_word, $captcha_code, $captchaPass)) { $strErrorMessage .= GetMessage("B_B_PC_CAPTCHA_ERROR") . " \n"; } } else { $strErrorMessage .= GetMessage("B_B_PC_CAPTCHA_ERROR") . " \n"; } }