示例#1
0
$module_id = "perfmon";
$RIGHT = $APPLICATION->GetGroupRight($module_id);
if ($RIGHT >= "R") {
    IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/options.php");
    IncludeModuleLangFile(__FILE__);
    $arAllOptions = array(array("max_display_url", GetMessage("PERFMON_OPTIONS_MAX_DISPLAY_URL"), array("text", 6)), array("warning_log", GetMessage("PERFMON_OPTIONS_WARNING_LOG"), array("checkbox")), array("cache_log", GetMessage("PERFMON_OPTIONS_CACHE_LOG"), array("checkbox")), array("sql_log", GetMessage("PERFMON_OPTIONS_SQL_LOG"), array("checkbox")), array("sql_backtrace", GetMessage("PERFMON_OPTIONS_SQL_BACKTRACE"), array("checkbox")), array("slow_sql_log", GetMessage("PERFMON_OPTIONS_SLOW_SQL_LOG"), array("checkbox"), GetMessage("PERFMON_OPTIONS_SLOW_SQL_NOTE")), array("slow_sql_time", GetMessage("PERFMON_OPTIONS_SLOW_SQL_TIME"), array("text", 6)));
    $aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("MAIN_TAB_SET"), "ICON" => "perfmon_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_SET")), array("DIV" => "edit2", "TAB" => GetMessage("MAIN_TAB_RIGHTS"), "ICON" => "perfmon_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_RIGHTS")));
    $tabControl = new CAdminTabControl("tabControl", $aTabs);
    CModule::IncludeModule($module_id);
    if ($REQUEST_METHOD == "POST" && strlen($Update . $Apply . $RestoreDefaults) > 0 && $RIGHT == "W" && check_bitrix_sessid()) {
        require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/perfmon/prolog.php";
        if ($_REQUEST["clear_data"] === "y") {
            CPerfomanceComponent::Clear();
            CPerfomanceSQL::Clear();
            CPerfomanceHit::Clear();
            CPerfomanceError::Clear();
            CPerfomanceCache::Clear();
        }
        if (array_key_exists("ACTIVE", $_REQUEST)) {
            $ACTIVE = intval($_REQUEST["ACTIVE"]);
            CPerfomanceKeeper::SetActive($ACTIVE > 0, time() + $ACTIVE);
        }
        if (strlen($RestoreDefaults) > 0) {
            COption::RemoveOption("perfmon");
        } else {
            foreach ($arAllOptions as $arOption) {
                $name = $arOption[0];
                $val = $_REQUEST[$name];
                if ($arOption[2][0] == "checkbox" && $val != "Y") {
                    $val = "N";
                }
    $arHeaders[] = array("id" => "ID", "content" => GetMessage("PERFMON_ERR_ID"), "align" => "right", "sort" => "ID", "default" => true);
    $arHeaders[] = array("id" => "HIT_ID", "content" => GetMessage("PERFMON_ERR_HIT_ID"), "align" => "right", "sort" => "HIT_ID", "default" => true);
}
$arHeaders[] = array("id" => "ERRNO", "content" => GetMessage("PERFMON_ERR_NO"), "align" => "right", "sort" => "ERRNO", "default" => true);
$arHeaders[] = array("id" => "ERRFILE", "content" => GetMessage("PERFMON_ERR_FILE"), "sort" => "ERRFILE", "default" => true);
$arHeaders[] = array("id" => "ERRLINE", "content" => GetMessage("PERFMON_ERR_LINE"), "sort" => "ERRLINE", "default" => true);
$arHeaders[] = array("id" => "ERRSTR", "content" => GetMessage("PERFMON_ERR_TEXT"), "sort" => "ERRSTR", "default" => true);
if ($group === "Y") {
    $arHeaders[] = array("id" => "COUNT", "content" => GetMessage("PERFMON_ERR_COUNT"), "align" => "right", "sort" => "COUNT", "default" => true);
}
$lAdmin->AddHeaders($arHeaders);
$arSelectedFields = $lAdmin->GetVisibleHeaderColumns();
if (!is_array($arSelectedFields) || count($arSelectedFields) < 1) {
    $arSelectedFields = array("ID", "HIT_ID", "ERRNO", "ERRFILE", "ERRLINE", "ERRSTR");
}
$cData = new CPerfomanceError();
$rsData = $cData->GetList($arSelectedFields, $arFilter, array($by => $order), $group === "Y");
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("PERFMON_ERR_PAGE")));
while ($arRes = $rsData->NavNext(true, "f_")) {
    if ($group == "Y") {
        $ID = md5($f_ERRFILE . "|" . $f_ERRLINE);
    } else {
        $ID = $f_ID;
    }
    $row = $lAdmin->AddRow($ID, $arRes);
    $row->AddViewField("ERRNO", $arErrorCodes[$f_ERRNO]);
    if ($bFileMan) {
        $row->AddViewField("ERRFILE", '<a href="fileman_file_edit.php?lang=' . LANGUAGE_ID . '&amp;full_src=Y&amp;site=&amp;set_filter=Y&amp;filter=&amp;path=' . urlencode(substr($arRes["ERRFILE"], strlen($_SERVER["DOCUMENT_ROOT"]))) . '">' . $f_ERRFILE . '</a>');
    }