function TxtToHTML( $str, // текст для преобразования $bMakeUrls = true, // true - преобразовавыть URL в <a href="URL">URL</a> $iMaxStringLen = 0, // максимальная длина фразы без пробелов или символов перевода каретки $QUOTE_ENABLED = "N", // Y - преобразовать <QUOTE>...</QUOTE> в рамку цитаты $NOT_CONVERT_AMPERSAND = "Y", // Y - не преобразовывать символ "&" в "&" $CODE_ENABLED = "N", // Y - преобразовать <CODE>...</CODE> в readonly textarea $BIU_ENABLED = "N", // Y - преобразовать <B>...</B> и т.д. в соответствующие HTML тэги $quote_table_class = "quotetable", // css класс на таблицу цитаты $quote_head_class = "tdquotehead", // css класс на первую TD таблицы цитаты $quote_body_class = "tdquote", // css класс на вторую TD таблицы цитаты $code_table_class = "codetable", // css класс на таблицу кода $code_head_class = "tdcodehead", // css класс на первую TD таблицы кода $code_body_class = "tdcodebody", // css класс на вторую TD таблицы кода $code_textarea_class = "codetextarea", // css класс на textarea в таблице кода $link_class = "txttohtmllink", // css класс на ссылках $arUrlEvent = array(), // массив в нем если заданы ключи EVENT1, EVENT2, EVENT3 то ссылки будут через // $arUrlEvent["SCRIPT"] (по умолчанию равен "/bitrix/redirect.php") $link_target = "_self" // tagret открытия страницы ) { global $QUOTE_ERROR, $QUOTE_OPENED, $QUOTE_CLOSED; $QUOTE_ERROR = $QUOTE_OPENED = $QUOTE_CLOSED = 0; $str = delete_special_symbols($str); //echo "\n<br>=====================\n<br><pre>".htmlspecialcharsbx($str)."</pre>\n<br>=======================\n<br>"; // вставим спецсимвол chr(2) там где в дальнейшем необходимо вставить пробел if($iMaxStringLen>0) $str = InsertSpaces($str, $iMaxStringLen, chr(2), true); // \ => chr(8) $str = str_replace("\\", chr(8), $str); // спецсимвол заменяющий слэш "\" // <quote>...</quote> => [quote]...[/quote] if ($QUOTE_ENABLED=="Y") $str = preg_replace("#(?:<|\[)(/?)quote(.*?)(?:>|\])#is", " [\\1quote]", $str); // <code>...</code> => [code]...[/code] // \n => chr(4) // \r => chr(5) if ($CODE_ENABLED=="Y") { $str = preg_replace("#<code(\s+[^>]*>|>)(.+?)</code(\s+[^>]*>|>)#is", "[code]\\2[/code]", $str); $str = preg_replace("#\[code(\s+[^\]]*\]|\])(.+?)\[/code(\s+[^\]]*\]|\])#ies", "convert_code_tag_for_html_before('\\2')", $str); } // <b>...</b> => [b]...[/b] // <i>...</i> => [i]...[/i] // <u>...</u> => [u]...[/u] if ($BIU_ENABLED=="Y") { $str = preg_replace("#<b(\s+[^>]*>|>)(.+?)</b(\s+[^>]*>|>)#is", "[b]\\2[/b]", $str); $str = preg_replace("#<i(\s+[^>]*>|>)(.+?)</i(\s+[^>]*>|>)#is", "[i]\\2[/i]", $str); $str = preg_replace("#<u(\s+[^>]*>|>)(.+?)</u(\s+[^>]*>|>)#is", "[u]\\2[/u]", $str); } // URL => chr(1).URL."/".chr(1) // EMail => chr(3).E-Mail.chr(3) if($bMakeUrls) { //hide @ from next regexp with chr(11) $str = preg_replace("#((http|https|ftp):\/\/[a-z:@,.'/\#\%=~\\&?*+\[\]_0-9\x01-\x08-]+)#ies", "extract_url(str_replace('@', chr(11), '\\1'))", $str); $str = preg_replace("#(([=_\.'0-9a-z+~\x01-\x08-]+)@([_0-9a-z\x01-\x08-]+\.)+[a-z]{2,10})#is", chr(3)."\\1".chr(3), $str); //replace back to @ $str = str_replace(chr(11), '@', $str); } // конвертация критичных символов if ($NOT_CONVERT_AMPERSAND!="Y") $str = str_replace("&", "&", $str); static $search=array("<",">","\"","'","%",")","(","+"); static $replace=array("<",">",""","'","%",")","(","+"); $str = str_replace($search, $replace, $str); // chr(1).URL."/".chr(1) => <a href="URL">URL</a> // chr(3).E-Mail.chr(3) => <a href="mailto:E-Mail">E-Mail</a> if($bMakeUrls) { $event1 = $arUrlEvent["EVENT1"]; $event2 = $arUrlEvent["EVENT2"]; $event3 = $arUrlEvent["EVENT3"]; $script = $arUrlEvent["SCRIPT"]; $str = preg_replace("#\x01([^\n\x01]+?)/\x01#ies", "convert_to_href('\\1', '".CUtil::addslashes($link_class)."', '".CUtil::addslashes($event1)."', '".CUtil::addslashes($event2)."', '".CUtil::addslashes($event3)."', '".CUtil::addslashes($script)."', '".CUtil::addslashes($link_target)."')", $str); $str = preg_replace("#\x03([^\n\x03]+?)\x03#ies", "convert_to_mailto('\\1', '".CUtil::addslashes($link_class)."')", $str); } $str = str_replace("\r\n", "\n", $str); $str = str_replace("\n", "<br />\n", $str); $str = preg_replace("# {2}#", " ", $str); $str = preg_replace("#\t#", " ", $str); // chr(2) => " " if($iMaxStringLen>0) $str = str_replace(chr(2), "<wbr>", $str); // [quote]...[/quote] => <table>...</table> if ($QUOTE_ENABLED=="Y") $str = preg_replace("#(\[quote(.*?)\](.*)\[/quote(.*?)\])#ies", "convert_quote_tag('\\1', '".CUtil::addslashes($quote_table_class)."', '".CUtil::addslashes($quote_head_class)."', '".CUtil::addslashes($quote_body_class)."')", $str); // [code]...[/code] => <textarea>...</textarea> // chr(4) => \n // chr(5) => \r if ($CODE_ENABLED=="Y") { $str = preg_replace("#\[code\](.*?)\[/code\]#ies", "convert_code_tag_for_html_after('\\1', '".CUtil::addslashes($code_table_class)."', '".CUtil::addslashes($code_head_class)."', '".CUtil::addslashes($code_body_class)."', '".CUtil::addslashes($code_textarea_class)."')", $str); $str = str_replace(chr(4), "\n", $str); $str = str_replace(chr(5), "\r", $str); $str = str_replace(chr(6), " ", $str); $str = str_replace(chr(7), "\t", $str); $str = str_replace(chr(16), "[", $str); $str = str_replace(chr(17), "]", $str); } // [b]...[/b] => <b>...</b> // [i]...[/i] => <i>...</i> // [u]...[/u] => <u>...</u> if ($BIU_ENABLED=="Y") { $str = preg_replace("#\[b\](.*?)\[/b\]#is", "<b>\\1</b>", $str); $str = preg_replace("#\[i\](.*?)\[/i\]#is", "<i>\\1</i>", $str); $str = preg_replace("#\[u\](.*?)\[/u\]#is", "<u>\\1</u>", $str); } // chr(8) => \ $str = str_replace(chr(8), "\\", $str); $str = delete_special_symbols($str); return $str; }
function TxtToHTML($str, $bMakeUrls = true, $iMaxStringLen = 0, $QUOTE_ENABLED = "N", $NOT_CONVERT_AMPERSAND = "Y", $CODE_ENABLED = "N", $BIU_ENABLED = "N", $quote_table_class = "quotetable", $quote_head_class = "tdquotehead", $quote_body_class = "tdquote", $code_table_class = "codetable", $code_head_class = "tdcodehead", $code_body_class = "tdcodebody", $code_textarea_class = "codetextarea", $link_class = "txttohtmllink", $arUrlEvent = array(), $link_target = "_self") { global $QUOTE_ERROR, $QUOTE_OPENED, $QUOTE_CLOSED; $QUOTE_ERROR = $QUOTE_OPENED = $QUOTE_CLOSED = 0; $str = delete_special_symbols($str); //echo "\n<br>=====================\n<br><pre>".htmlspecialcharsbx($str)."</pre>\n<br>=======================\n<br>"; // вставим спецсимвол chr(2) там где в дальнейшем необходимо вставить пробел if ($iMaxStringLen > 0) { $str = InsertSpaces($str, $iMaxStringLen, chr(2), true); } // \ => chr(8) $str = str_replace("\\", chr(8), $str); // спецсимвол заменяющий слэш "\" // <quote>...</quote> => [quote]...[/quote] if ($QUOTE_ENABLED == "Y") { $str = preg_replace("#(?:<|\\[)(/?)quote(.*?)(?:>|\\])#is", " [\\1quote]", $str); } // <code>...</code> => [code]...[/code] // \n => chr(4) // \r => chr(5) if ($CODE_ENABLED == "Y") { $str = preg_replace("#<code(\\s+[^>]*>|>)(.+?)</code(\\s+[^>]*>|>)#is", "[code]\\2[/code]", $str); $str = preg_replace("#\\[code(\\s+[^\\]]*\\]|\\])(.+?)\\[/code(\\s+[^\\]]*\\]|\\])#ies", "convert_code_tag_for_html_before('\\2')", $str); } // <b>...</b> => [b]...[/b] // <i>...</i> => [i]...[/i] // <u>...</u> => [u]...[/u] if ($BIU_ENABLED == "Y") { $str = preg_replace("#<b(\\s+[^>]*>|>)(.+?)</b(\\s+[^>]*>|>)#is", "[b]\\2[/b]", $str); $str = preg_replace("#<i(\\s+[^>]*>|>)(.+?)</i(\\s+[^>]*>|>)#is", "[i]\\2[/i]", $str); $str = preg_replace("#<u(\\s+[^>]*>|>)(.+?)</u(\\s+[^>]*>|>)#is", "[u]\\2[/u]", $str); } // URL => chr(1).URL."/".chr(1) // EMail => chr(3).E-Mail.chr(3) if ($bMakeUrls) { //hide @ from next regexp with chr(11) $str = preg_replace("#((http|https|ftp):\\/\\/[a-z:@,.'/\\#\\%=~\\&?*+\\[\\]_0-9--]+)#ies", "extract_url(str_replace('@', chr(11), '\\1'))", $str); $str = preg_replace("#(([=_\\.'0-9a-z+~--]+)@([_0-9a-z--]+\\.)+[a-z]{2,10})#is", chr(3) . "\\1" . chr(3), $str); //replace back to @ $str = str_replace(chr(11), '@', $str); } // конвертация критичных символов if ($NOT_CONVERT_AMPERSAND != "Y") { $str = str_replace("&", "&", $str); } static $search = array("<", ">", "\"", "'", "%", ")", "(", "+"); static $replace = array("<", ">", """, "'", "%", ")", "(", "+"); $str = str_replace($search, $replace, $str); // chr(1).URL."/".chr(1) => <a href="URL">URL</a> // chr(3).E-Mail.chr(3) => <a href="mailto:E-Mail">E-Mail</a> if ($bMakeUrls) { $event1 = $arUrlEvent["EVENT1"]; $event2 = $arUrlEvent["EVENT2"]; $event3 = $arUrlEvent["EVENT3"]; $script = $arUrlEvent["SCRIPT"]; $str = preg_replace("#([^\n]+?)/#ies", "convert_to_href('\\1', '" . CUtil::addslashes($link_class) . "', '" . CUtil::addslashes($event1) . "', '" . CUtil::addslashes($event2) . "', '" . CUtil::addslashes($event3) . "', '" . CUtil::addslashes($script) . "', '" . CUtil::addslashes($link_target) . "')", $str); $str = preg_replace("#([^\n]+?)#ies", "convert_to_mailto('\\1', '" . CUtil::addslashes($link_class) . "')", $str); } $str = str_replace("\r\n", "\n", $str); $str = str_replace("\n", "<br />\n", $str); $str = preg_replace("# {2}#", " ", $str); $str = preg_replace("#\t#", " ", $str); // chr(2) => " " if ($iMaxStringLen > 0) { $str = str_replace(chr(2), "<wbr>", $str); } // [quote]...[/quote] => <table>...</table> if ($QUOTE_ENABLED == "Y") { $str = preg_replace("#(\\[quote(.*?)\\](.*)\\[/quote(.*?)\\])#ies", "convert_quote_tag('\\1', '" . CUtil::addslashes($quote_table_class) . "', '" . CUtil::addslashes($quote_head_class) . "', '" . CUtil::addslashes($quote_body_class) . "')", $str); } // [code]...[/code] => <textarea>...</textarea> // chr(4) => \n // chr(5) => \r if ($CODE_ENABLED == "Y") { $str = preg_replace("#\\[code\\](.*?)\\[/code\\]#ies", "convert_code_tag_for_html_after('\\1', '" . CUtil::addslashes($code_table_class) . "', '" . CUtil::addslashes($code_head_class) . "', '" . CUtil::addslashes($code_body_class) . "', '" . CUtil::addslashes($code_textarea_class) . "')", $str); $str = str_replace(chr(4), "\n", $str); $str = str_replace(chr(5), "\r", $str); $str = str_replace(chr(6), " ", $str); $str = str_replace(chr(7), "\t", $str); $str = str_replace(chr(16), "[", $str); $str = str_replace(chr(17), "]", $str); } // [b]...[/b] => <b>...</b> // [i]...[/i] => <i>...</i> // [u]...[/u] => <u>...</u> if ($BIU_ENABLED == "Y") { $str = preg_replace("#\\[b\\](.*?)\\[/b\\]#is", "<b>\\1</b>", $str); $str = preg_replace("#\\[i\\](.*?)\\[/i\\]#is", "<i>\\1</i>", $str); $str = preg_replace("#\\[u\\](.*?)\\[/u\\]#is", "<u>\\1</u>", $str); } // chr(8) => \ $str = str_replace(chr(8), "\\", $str); $str = delete_special_symbols($str); return $str; }
// navigation setup $lAdmin->NavText($rsData->GetNavPrint(GetMessage("SEARCH_PHL_PHRASES"))); $aContext = array(); $lAdmin->AddAdminContextMenu($aContext); $arHeaders = array(array("id" => "ID", "content" => GetMessage("SEARCH_PHL_ID"), "sort" => "ID", "default" => true, "align" => "right"), array("id" => "SITE_ID", "content" => GetMessage("SEARCH_PHL_SITE_ID"), "default" => true), array("id" => "PHRASE", "content" => GetMessage("SEARCH_PHL_PHRASE"), "sort" => "PHRASE", "default" => true), array("id" => "TAGS", "content" => GetMessage("SEARCH_PHL_TAGS"), "sort" => "TAGS", "default" => true), array("id" => "TIMESTAMP_X", "content" => GetMessage("SEARCH_PHL_TIMESTAMP_X"), "sort" => "TIMESTAMP_X", "default" => true), array("id" => "URL_TO", "content" => GetMessage("SEARCH_PHL_URL_TO"), "sort" => "URL_TO", "default" => true), array("id" => "RESULT_COUNT", "content" => GetMessage("SEARCH_PHL_RESULT_COUNT"), "sort" => "RESULT_COUNT", "default" => true, "align" => "right"), array("id" => "PAGES", "content" => GetMessage("SEARCH_PHL_PAGES"), "title" => GetMessage("SEARCH_PHL_PAGES_ALT"), "sort" => "PAGES", "default" => true, "align" => "right")); if (IsModuleInstalled('statistic')) { $arHeaders[] = array("id" => "STAT_SESS_ID", "content" => GetMessage("SEARCH_PHL_STAT_SESS_ID"), "sort" => "STAT_SESS_ID", "default" => true, "align" => "right"); } $lAdmin->AddHeaders($arHeaders); $i = 0; while ($arRes = $rsData->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arRes); if ($_REQUEST["mode"] != "excel") { $row->AddViewField("TIMESTAMP_X", str_replace(" ", " ", $f_TIMESTAMP_X)); } $row->AddViewField("URL_TO", ($f_URL_TO_SITE_ID ? "[" . $f_URL_TO_SITE_ID . "] " : "") . "<a " . ($f_URL_TO_404 == "Y" ? 'style="color:red"' : '') . " title=\"" . GetMessage("SEARCH_PHL_LINK_OPEN") . "\" href=\"{$f_URL_TO}\">" . TruncateText(InsertSpaces($f_URL_TO, 50, "<wbr>"), 100) . "</a> "); $row->AddViewField("STAT_SESS_ID", "<a title=\"" . GetMessage("SEARCH_PHL_SESSION") . "\" href=\"session_list.php?lang=" . LANGUAGE_ID . "&find_id={$f_STAT_SESS_ID}&find_id_exact_match=Y&set_filter=Y\">{$f_STAT_SESS_ID}</a> "); } $lAdmin->AddFooter(array(array("title" => GetMessage("MAIN_ADMIN_LIST_SELECTED"), "value" => $rsData->SelectedRowsCount()))); $lAdmin->CheckListMode(); /*************************************************************************** HTML form ****************************************************************************/ $APPLICATION->SetTitle(GetMessage("SEARCH_PHL_TITLE")); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; ?> <form name="form1" method="GET" action="<?php echo $APPLICATION->GetCurPage(); ?> ">
public static function EndBuffer() { $err_mess = "File: ".__FILE__."<br>Line: "; global $APPLICATION, $arHashLink; $DB = CDatabase::GetModuleConnection('statistic'); if (defined("ADMIN_SECTION") && ADMIN_SECTION===true) return; if (defined("BX_STATISTIC_BUFFER_USED") && BX_STATISTIC_BUFFER_USED===true) { $content = ob_get_contents(); ob_end_clean(); // this JS will open new windows with statistics data ob_start(); ?> <script language="JavaScript"> function ShowStatLinkPage() { try { ShowStatLinkPageEx(); } catch (e) { alert('<?echo GetMessage("STAT_LINK_STAT_PANEL_BUTTON_ALERT")?>'); } } </script> <? $content .= ob_get_contents(); ob_end_clean(); $arUniqLink = array(); $arHashLink = array(); // parse the content in order to get links if(preg_match_all("#<a[^>]+?href\\s*=\\s*([\"'])(.*?)\\1#is", $content, $arr)) { foreach($arr[2] as $link) { if (!__IsHiddenLink($link)) { // relative URL found $link = __GetFullRequestUri(__GetFullCurPage($link)); if (strpos($link, $_SERVER["HTTP_HOST"])!==false) { $arUniqLink[crc32ex($link)] = $link; } } } } // we found some links if (count($arUniqLink)>0) { // read database to get their data $SUM = 0; $MAX = false; $CURRENT_PAGE = __GetFullRequestUri(__GetFullCurPage()); $CURRENT_PAGE_CRC32 = crc32ex($CURRENT_PAGE); foreach($arUniqLink as $link_crc => $link) { if ($CURRENT_PAGE != $link) { $strSql = " SELECT LAST_PAGE_HASH, sum(COUNTER) CNT FROM b_stat_path WHERE PREV_PAGE_HASH = '".$CURRENT_PAGE_CRC32."' and LAST_PAGE_HASH = '".$link_crc."' GROUP BY LAST_PAGE_HASH "; $rs = $DB->Query($strSql, false, $err_mess.__LINE__); $ar = $rs->Fetch(); $CNT = intval($ar["CNT"]); if($CNT > 0) { $arHashLink[$link_crc] = array( "LINK" => $link, "CNT" => $CNT, ); $SUM += $CNT; if($MAX === false || ($CNT > $MAX)) $MAX = $CNT; } } } // если имеем массив количеств переходов по ссылкам то if((count($arHashLink) > 0) && ($SUM > 0)) { // отсортируем ссылки в порядке убывания количества переходов и // 1) присвоим каждой ссылке порядковый номер // 2) посчитаем процент переходов по каждой ссылке uasort($arHashLink, "__SortLinkStat"); $i=0; foreach($arHashLink as $link_crc => $arLink) { $i++; $arHashLink[$link_crc]["ID"] = $i; $arHashLink[$link_crc]["PERCENT"] = round((100*$arLink["CNT"])/$SUM, 1); } // парсим контент и добавляем к тэгам <a> желтую табличку с процентом переходов $pcre_backtrack_limit = intval(ini_get("pcre.backtrack_limit")); $content_len = function_exists('mb_strlen')? mb_strlen($content, 'latin1'): strlen($content); $content_len++; if($pcre_backtrack_limit < $content_len) @ini_set("pcre.backtrack_limit", $content_len); $content = preg_replace_callback("#(<a[^>]+?href\\s*=\\s*)([\"'])(.*?)(\\2.*?>)(.*?)(</.+?>)#is", "__ModifyATags", $content); // сформируем диаграмму переходов для данной страницы ob_start(); ?> <style> div.stat_pages h2 { background-color:#EEEEEE; font-family:Verdana,Arial,sans-serif; font-size:82%; padding:4px 10px; } div.stat_pages p { font-family:Verdana,Arial,sans-serif; font-size:82%; } div.stat_pages td { font-family:Verdana,Arial,sans-serif; font-size:70%; border: 1px solid #BDC6E0; padding:3px; background-color: white; } div.stat_pages table { border-collapse:collapse; } div.stat_pages td.head { background-color:#E6E9F4; } div.stat_pages td.tail { background-color:#EAEDF7; } </style> <div class="stat_pages"> <h2><?php echo GetMessage("STAT_LINK_STAT"); ?> </h2> <p><?php echo $CURRENT_PAGE; ?> </p> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td class="head" align="center">#</td> <td class="head"><?php echo GetMessage("STAT_LINK"); ?> </td> <td colspan="2" class="head"><?php echo GetMessage("STAT_CLICKS"); ?> </td> <td class="head"> </td> </tr> <? $max_relation = ($MAX*100)/90; foreach($arHashLink as $ar): $w = round(($ar["CNT"]*100)/$max_relation); ?> <tr> <td valign="top" align="right" width="0%" nowrap><?php echo $ar["ID"]; ?> .</td> <td valign="top" width="50%"><?php echo InsertSpaces($ar["LINK"], 60, "<wbr>"); ?> </td> <td valign="top" align="right" width="5%" nowrap><?php echo $ar["PERCENT"] . "%"; ?> </td> <td valign="top" align="right" width="5%" nowrap><?php echo $ar["CNT"]; ?> </td> <td valign="top" nowrap width="40%"><img src="/bitrix/images/statistic/votebar.gif" width="<?echo ($w==0) ? "0" : $w."%"?>" height="10" border=0 alt=""></td> </tr> <?endforeach?> <tr> <td width="0%" colspan="3" nowrap align="right" class="tail"><?echo GetMessage("STAT_TOTAL")?></td> <td width="0%" nowrap align="right" class="tail"><?php echo $SUM; ?> </td> <td width="100%" class="tail"> </td> </tr> </table> <p><form><input type="button" onClick="window.close()" value="<?echo GetMessage("STAT_CLOSE")?>"></form></p> </div> <? $stat_table = trim(ob_get_contents()); $js_table = "wnd.document.write('".CUtil::JSEscape($stat_table)."');"; ob_end_clean(); // сформируем JS открывающий отдельное окно со статистикой переходов ob_start(); ?> <script language="JavaScript"> function ShowStatLinkPageEx() { var top=0, left=0; var width=800, height=600; if(width > screen.width-10 || height > screen.height-28) scroll = "yes"; if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14); if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5); width = Math.min(width, screen.width-10); height = Math.min(height, screen.height-28); var wnd = window.open("","","scrollbars=yes,resizable=yes,width="+width+",height="+height+",left="+left+",top="+top); wnd.document.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"); wnd.document.write("<html><head>\n"); wnd.document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=<?echo LANG_CHARSET?>\">\n"); wnd.document.write("<"+"script language=\'JavaScript\'>\n"); wnd.document.write("<!--\n"); wnd.document.write("function KeyPress()\n"); wnd.document.write("{\n"); wnd.document.write(" if(window.event.keyCode == 27)\n"); wnd.document.write(" window.close();\n"); wnd.document.write("}\n"); wnd.document.write("//-->\n"); wnd.document.write("</"+"script>\n"); wnd.document.write("<title><?php echo GetMessage("STAT_LINK_STAT_TITLE"); ?> </title></head>\n"); wnd.document.write("<body style=\"padding:10px;\" topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onKeyPress=\"KeyPress()\">\n"); <?php echo $js_table; ?> wnd.document.write("</body>"); wnd.document.write("</html>"); wnd.document.close(); } </script> <? $js = ob_get_contents(); ob_end_clean(); } } echo $content.$js; } }
function TxtToHTML($str, $bMakeUrls = true, $iMaxStringLen = 0, $QUOTE_ENABLED = "N", $NOT_CONVERT_AMPERSAND = "Y", $CODE_ENABLED = "N", $BIU_ENABLED = "N", $quote_table_class = "quotetable", $quote_head_class = "tdquotehead", $quote_body_class = "tdquote", $code_table_class = "codetable", $code_head_class = "tdcodehead", $code_body_class = "tdcodebody", $code_textarea_class = "codetextarea", $link_class = "txttohtmllink", $arUrlEvent = array(), $link_target = "_self") { global $QUOTE_ERROR, $QUOTE_OPENED, $QUOTE_CLOSED; $QUOTE_ERROR = $QUOTE_OPENED = $QUOTE_CLOSED = 0; $str = delete_special_symbols($str); // вставим спецсимвол chr(2) там где в дальнейшем необходимо вставить пробел if ($iMaxStringLen > 0) { $str = InsertSpaces($str, $iMaxStringLen, chr(2), true); } // \ => chr(8) $str = str_replace("\\", chr(8), $str); // спецсимвол замен¤ющий слэш "\" // <quote>...</quote> => [quote]...[/quote] if ($QUOTE_ENABLED == "Y") { $str = preg_replace("#(?:<|\\[)(/?)quote(.*?)(?:>|\\])#is", " [\\1quote]", $str); } // <code>...</code> => [code]...[/code] // \n => chr(4) // \r => chr(5) if ($CODE_ENABLED == "Y") { $helper = new CConvertorsPregReplaceHelper(""); $str = preg_replace("#<code(\\s+[^>]*>|>)(.+?)</code(\\s+[^>]*>|>)#is", "[code]\\2[/code]", $str); $str = preg_replace_callback("#\\[code(\\s+[^\\]]*\\]|\\])(.+?)\\[/code(\\s+[^\\]]*\\]|\\])#is", array($helper, "convertCodeTagForHtmlBefore"), $str); } // <b>...</b> => [b]...[/b] // <i>...</i> => [i]...[/i] // <u>...</u> => [u]...[/u] if ($BIU_ENABLED == "Y") { $str = preg_replace("#<b(\\s+[^>]*>|>)(.+?)</b(\\s+[^>]*>|>)#is", "[b]\\2[/b]", $str); $str = preg_replace("#<i(\\s+[^>]*>|>)(.+?)</i(\\s+[^>]*>|>)#is", "[i]\\2[/i]", $str); $str = preg_replace("#<u(\\s+[^>]*>|>)(.+?)</u(\\s+[^>]*>|>)#is", "[u]\\2[/u]", $str); } // URL => chr(1).URL."/".chr(1) // EMail => chr(3).E-Mail.chr(3) if ($bMakeUrls) { //hide @ from next regexp with chr(11) $str = preg_replace_callback("#((http|https|ftp):\\/\\/[a-z:@,.'/\\#\\%=~\\&?*+\\[\\]_0-9--]+)#is", array("CConvertorsPregReplaceHelper", "extractUrl"), $str); $str = preg_replace("#(([=_\\.'0-9a-z+~--]+)@[_0-9a-z--.]+\\.[a-z]{2,10})#is", chr(3) . "\\1" . chr(3), $str); //replace back to @ $str = str_replace(chr(11), '@', $str); } // конвертаци¤ критичных символов if ($NOT_CONVERT_AMPERSAND != "Y") { $str = str_replace("&", "&", $str); } static $search = array("<", ">", "\"", "'", "%", ")", "(", "+"); static $replace = array("<", ">", """, "'", "%", ")", "(", "+"); $str = str_replace($search, $replace, $str); // chr(1).URL."/".chr(1) => <a href="URL">URL</a> // chr(3).E-Mail.chr(3) => <a href="mailto:E-Mail">E-Mail</a> if ($bMakeUrls) { $script = $arUrlEvent["SCRIPT"]; $helper = new CConvertorsPregReplaceHelper(""); $helper->setLinkClass($link_class); $helper->setLinkTarget($link_target); $helper->setEvents($arUrlEvent["EVENT1"], $arUrlEvent["EVENT2"], $arUrlEvent["EVENT3"]); if (strlen($script)) { $helper->setScript($script); } $str = preg_replace_callback("#([^\n]+?)/#is", array($helper, "convertToHref"), $str); $str = preg_replace_callback("#([^\n]+?)#is", array($helper, "convertToMailTo"), $str); } $str = str_replace("\r\n", "\n", $str); $str = str_replace("\n", "<br />\n", $str); $str = preg_replace("# {2}#", " ", $str); $str = preg_replace("#\t#", " ", $str); // chr(2) => " " if ($iMaxStringLen > 0) { $str = str_replace(chr(2), "<wbr>", $str); } // [quote]...[/quote] => <table>...</table> if ($QUOTE_ENABLED == "Y") { $helper = new CConvertorsPregReplaceHelper(""); $helper->setQuoteClasses($quote_table_class, $quote_head_class, $quote_body_class); $str = preg_replace_callback("#(\\[quote(.*?)\\](.*)\\[/quote(.*?)\\])#is", array($helper, "convertQuoteTag"), $str); } // [code]...[/code] => <textarea>...</textarea> // chr(4) => \n // chr(5) => \r if ($CODE_ENABLED == "Y") { $helper = new CConvertorsPregReplaceHelper(""); $helper->setCodeClasses($code_table_class, $code_head_class, $code_body_class, $code_textarea_class); $str = preg_replace_callback("#\\[code\\](.*?)\\[/code\\]#is", array($helper, "convertCodeTagForHtmlAfter"), $str); $str = str_replace(chr(4), "\n", $str); $str = str_replace(chr(5), "\r", $str); $str = str_replace(chr(6), " ", $str); $str = str_replace(chr(7), "\t", $str); $str = str_replace(chr(16), "[", $str); $str = str_replace(chr(17), "]", $str); } // [b]...[/b] => <b>...</b> // [i]...[/i] => <i>...</i> // [u]...[/u] => <u>...</u> if ($BIU_ENABLED == "Y") { $str = preg_replace("#\\[b\\](.*?)\\[/b\\]#is", "<b>\\1</b>", $str); $str = preg_replace("#\\[i\\](.*?)\\[/i\\]#is", "<i>\\1</i>", $str); $str = preg_replace("#\\[u\\](.*?)\\[/u\\]#is", "<u>\\1</u>", $str); } // chr(8) => \ $str = str_replace(chr(8), "\\", $str); $str = delete_special_symbols($str); return $str; }
function StatAdminListFormatURL($url, $arOptions = array()) { $new_window = false; if (isset($arOptions["new_window"]) && $arOptions["new_window"] == true) { $new_window = true; } $href_class = ''; if (isset($arOptions["attention"]) && $arOptions["attention"] == true) { $href_class = 'stat_attention'; } $href_title = ''; if (isset($arOptions["title"])) { $href_title = htmlspecialcharsex($arOptions["title"]); } $max_display_chars = 0; if (isset($arOptions["max_display_chars"])) { if ($arOptions["max_display_chars"] === 'default') { $max_display_chars = 80; } elseif ($arOptions["max_display_chars"] > 0) { $max_display_chars = $arOptions["max_display_chars"]; } } $chars_per_line = 0; if (isset($arOptions["chars_per_line"])) { if ($arOptions["chars_per_line"] === 'default') { $chars_per_line = 33; } elseif ($arOptions["chars_per_line"] > 0) { $chars_per_line = $arOptions["chars_per_line"]; } } $line_delimiter = '<br />'; if (isset($arOptions["line_delimiter"])) { $line_delimiter = $arOptions["line_delimiter"]; } $kill_sessid = true; if (isset($arOptions["kill_sessid"])) { $kill_sessid = $arOptions["kill_sessid"]; } if ($kill_sessid) { $url = preg_replace('/(sessid=[a-zA-Z0-9]+)/', '', $url); $url = str_replace('&&', '&', $url); $url = str_replace('?&', '?', $url); $url = trim($url, "?&"); } $htmlA = '<a href="' . htmlspecialcharsex($url) . '"'; if ($new_window) { $htmlA .= ' target="_blank"'; } if ($href_class) { $htmlA .= ' class="' . $href_class . '"'; } if ($href_title) { $htmlA .= ' title="' . $href_title . '"'; } $htmlA .= '>'; $url_display = $url; if ($max_display_chars > 0 && strlen($url) >= $max_display_chars) { $url_display = substr($url, 0, intval($max_display_chars * 0.7)) . '...' . substr($url, -intval($max_display_chars * 0.2)); } if ($chars_per_line > 0) { $url_display = InsertSpaces($url_display, $chars_per_line, ""); $url_display = htmlspecialcharsbx($url_display); $url_display = str_replace("", $line_delimiter, $url_display); } else { $url_display = htmlspecialcharsbx($url_display); } return $htmlA . $url_display . '</a>'; }