$arSelectedFields = $lAdmin->GetVisibleHeaderColumns();
if (!is_array($arSelectedFields) || count($arSelectedFields) < 1) {
    $arSelectedFields = array("ID", "RULE_TYPE", "ACTIVE", "ADMIN_SECTION", "SITE_ID", "SORT", "NAME", "ACTIVE_FROM", "ACTIVE_TO");
}
$arVisibleColumnsMap = array();
foreach ($arSelectedFields as $value) {
    $arVisibleColumnsMap[$value] = true;
}
if (array_key_exists("ACTIVE_FROM", $arVisibleColumnsMap)) {
    $arSelectedFields[] = "ACTIVE_FROM_TIMESTAMP";
}
if (array_key_exists("ACTIVE_TO", $arVisibleColumnsMap)) {
    $arSelectedFields[] = "ACTIVE_TO_TIMESTAMP";
}
$cData = new CSecurityIPRule();
$rsData = $cData->GetList($arSelectedFields, $arFilter, array($by => $order, "ID" => "DESC"));
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("SEC_IP_LIST_PAGER")));
$current_time = time();
while ($arRes = $rsData->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_ID, $arRes);
    $row->AddViewField("ADMIN_SECTION", $f_ADMIN_SECTION == "Y" ? GetMessage("MAIN_YES") : GetMessage("MAIN_NO"));
    $row->AddViewField("RULE_TYPE", $arAccessTypes[$f_RULE_TYPE]);
    if ($f_ACTIVE == "Y" && ($f_ACTIVE_FROM == "" || intval($f_ACTIVE_FROM_TIMESTAMP) < $current_time) && ($f_ACTIVE_TO == "" || intval($f_ACTIVE_TO_TIMESTAMP) > $current_time)) {
        $row->AddViewField("ACTIVE", '<div class="lamp-green"></div>');
    } else {
        $row->AddViewField("ACTIVE", '<div class="lamp-red"></div>');
    }
    if (array_key_exists("INCL_PATH", $arVisibleColumnsMap)) {
        $arMasks = CSecurityIPRule::GetRuleInclMasks($f_ID);
    $error_level = GetMessage("SEC_PANEL_ERROR1");
} elseif ($reporting_level == (E_ALL ^ E_NOTICE)) {
    $error_level = GetMessage("SEC_PANEL_ERROR2");
} elseif ($reporting_level == 0) {
    $error_level = GetMessage("SEC_PANEL_ERROR3");
} else {
    $error_level = GetMessage("SEC_PANEL_ERROR4");
}
$data['std']['ITEMS'][] = array("IS_OK" => $error_level == GetMessage("SEC_PANEL_ERROR1") || $error_level == GetMessage("SEC_PANEL_ERROR3"), "KPI_NAME" => GetMessage("SEC_PANEL_ERROR_NAME"), "KPI_VALUE" => $error_level, "KPI_RECOMMENDATION" => $error_level == GetMessage("SEC_PANEL_ERROR1") || $error_level == GetMessage("SEC_PANEL_ERROR3") ? '&nbsp;' : ($USER->CanDoOperation('edit_other_settings') ? '<a href="settings.php?lang=' . LANGUAGE_ID . '&amp;mid=main&amp;back_url_settings=' . urlencode('security_panel.php?lang=' . LANGUAGE_ID) . '">' . GetMessage("SEC_PANEL_ERROR1") . '</a>' : GetMessage("SEC_PANEL_ERROR1")));
global $DB;
$data['std']['ITEMS'][] = array("IS_OK" => !$DB->debug, "KPI_NAME" => GetMessage("SEC_PANEL_QUERY_DEBUG"), "KPI_VALUE" => $DB->debug ? GetMessage("SEC_PANEL_QUERY_DEBUG_VALUE_ON") : GetMessage("SEC_PANEL_QUERY_DEBUG_VALUE_OFF"), "KPI_RECOMMENDATION" => !$DB->debug ? '&nbsp;' : (IsModuleInstalled('fileman') && ($USER->CanDoOperation('fileman_admin_files') || $USER->CanDoOperation('fileman_edit_existent_files')) ? GetMessage("SEC_PANEL_QUERY_DEBUG_RECOMMENDATION_WITH_HREF", array("#HREF#" => '/bitrix/admin/fileman_file_edit.php?lang=' . LANGUAGE_ID . '&amp;full_src=Y&amp;path=' . urlencode(BX_PERSONAL_ROOT . '/php_interface/dbconn.php') . '&amp;back_url=' . urlencode('/bitrix/admin/security_panel.php?lang=' . LANGUAGE_ID))) : GetMessage("SEC_PANEL_QUERY_DEBUG_RECOMMENDATION_WO_HREF")));
$bEventLog = COption::GetOptionString("main", "event_log_logout", "N") === "Y" && COption::GetOptionString("main", "event_log_login_success", "N") === "Y" && COption::GetOptionString("main", "event_log_login_fail", "N") === "Y" && COption::GetOptionString("main", "event_log_register", "N") === "Y" && COption::GetOptionString("main", "event_log_register_fail", "N") === "Y" && COption::GetOptionString("main", "event_log_password_request", "N") === "Y" && COption::GetOptionString("main", "event_log_password_change", "N") === "Y" && COption::GetOptionString("main", "event_log_user_delete", "N") === "Y" && COption::GetOptionString("main", "event_log_user_groups", "N") === "Y" && COption::GetOptionString("main", "event_log_group_policy", "N") === "Y" && COption::GetOptionString("main", "event_log_module_access", "N") === "Y" && COption::GetOptionString("main", "event_log_file_access", "N") === "Y" && COption::GetOptionString("main", "event_log_task", "N") === "Y";
$data['high']['ITEMS'][] = array("IS_OK" => $bEventLog, "KPI_NAME" => GetMessage("SEC_PANEL_EVENT_LOG_NAME"), "KPI_VALUE" => $bEventLog ? GetMessage("SEC_PANEL_EVENT_LOG_VALUE_ON") : GetMessage("SEC_PANEL_EVENT_LOG_VALUE_OFF"), "KPI_RECOMMENDATION" => $bEventLog ? '&nbsp;' : ($USER->CanDoOperation('edit_other_settings') ? '<a href="settings.php?lang=' . LANGUAGE_ID . '&amp;mid=main&amp;back_url_settings=' . urlencode('security_panel.php?lang=' . LANGUAGE_ID) . '&amp;tabControl_active_tab=edit8">' . GetMessage("SEC_PANEL_EVENT_LOG_RECOMMENDATION") . '</a>' : GetMessage("SEC_PANEL_EVENT_LOG_RECOMMENDATION")));
$bSecurityFrame = CSecurityFrame::IsActive();
$data['high']['ITEMS'][] = array("IS_OK" => $bSecurityFrame, "KPI_NAME" => GetMessage("SEC_PANEL_FRAME_NAME"), "KPI_VALUE" => $bSecurityFrame ? GetMessage("SEC_PANEL_FRAME_VALUE_ON") : GetMessage("SEC_PANEL_FRAME_VALUE_OFF"), "KPI_RECOMMENDATION" => $bSecurityFrame ? '&nbsp;' : ($USER->CanDoOperation('security_frame_settings_write') ? '<a href="security_frame.php?lang=' . LANGUAGE_ID . '&amp;return_url=' . urlencode('security_panel.php?lang=' . LANGUAGE_ID) . '">' . GetMessage("SEC_PANEL_FRAME_RECOMMENDATION") . '</a>' : GetMessage("SEC_PANEL_FRAME_RECOMMENDATION")));
$rsIPRule = CSecurityIPRule::GetList(array(), array("=RULE_TYPE" => "A", "=ADMIN_SECTION" => "Y", "=SITE_ID" => false, "=SORT" => 10, "=ACTIVE_FROM" => false, "=ACTIVE_TO" => false), array("ID" => "ASC"));
$arIPRule = $rsIPRule->Fetch();
if ($arIPRule) {
    $bIPProtection = $arIPRule["ACTIVE"] == "Y";
} else {
    $bIPProtection = false;
}
$msgStopListDisabled = CSecurityIPRule::CheckAntiFile(true);
$data['high']['ITEMS'][] = array("IS_OK" => $bIPProtection && $msgStopListDisabled === false, "KPI_NAME" => GetMessage("SEC_PANEL_IPBLOCK_NAME"), "KPI_VALUE" => $bIPProtection && $msgStopListDisabled === false ? GetMessage("SEC_PANEL_IPBLOCK_VALUE_ON") : GetMessage("SEC_PANEL_IPBLOCK_VALUE_OFF"), "KPI_RECOMMENDATION" => $bIPProtection ? $msgStopListDisabled === false ? '&nbsp;' : $msgStopListDisabled->Show() : ($USER->CanDoOperation('security_iprule_admin_settings_write') ? '<a href="security_iprule_admin.php?lang=' . LANGUAGE_ID . '&amp;return_url=' . urlencode('security_panel.php?lang=' . LANGUAGE_ID) . '">' . GetMessage("SEC_PANEL_IPBLOCK_RECOMMENDATION") . '</a>' : GetMessage("SEC_PANEL_IPBLOCK_RECOMMENDATION")));
$bSessionsDB = COption::GetOptionString("security", "session") == "Y";
$data['high']['ITEMS'][] = array("IS_OK" => $bSessionsDB, "KPI_NAME" => GetMessage("SEC_PANEL_SESSDB_NAME"), "KPI_VALUE" => $bSessionsDB ? GetMessage("SEC_PANEL_SESSDB_VALUE_ON") : GetMessage("SEC_PANEL_SESSDB_VALUE_OFF"), "KPI_RECOMMENDATION" => $bSessionsDB ? '&nbsp;' : ($USER->CanDoOperation('security_session_settings_write') ? '<a href="security_session.php?lang=' . LANGUAGE_ID . '&amp;return_url=' . urlencode('security_panel.php?lang=' . LANGUAGE_ID) . '&amp;tabControl_active_tab=savedb">' . GetMessage("SEC_PANEL_SESSDB_RECOMMENDATION") . '</a>' : GetMessage("SEC_PANEL_SESSDB_RECOMMENDATION")));
$bSessionTTL = COption::GetOptionString("main", "use_session_id_ttl", "N") == "Y" && COption::GetOptionInt("main", "session_id_ttl", 0) > 0;
$data['high']['ITEMS'][] = array("IS_OK" => $bSessionTTL, "KPI_NAME" => GetMessage("SEC_PANEL_SESSID_NAME"), "KPI_VALUE" => $bSessionTTL ? GetMessage("SEC_PANEL_SESSID_VALUE_ON") : GetMessage("SEC_PANEL_SESSID_VALUE_OFF"), "KPI_RECOMMENDATION" => $bSessionTTL ? '&nbsp;' : ($USER->CanDoOperation('security_session_settings_write') ? '<a href="security_session.php?lang=' . LANGUAGE_ID . '&amp;return_url=' . urlencode('security_panel.php?lang=' . LANGUAGE_ID) . '&amp;tabControl_active_tab=sessid">' . GetMessage("SEC_PANEL_SESSID_RECOMMENDATION") . '</a>' : GetMessage("SEC_PANEL_SESSID_RECOMMENDATION")));
$bRedirect = CSecurityRedirect::IsActive();
$data['high']['ITEMS'][] = array("IS_OK" => $bRedirect, "KPI_NAME" => GetMessage("SEC_PANEL_ANTIFISHING_NAME"), "KPI_VALUE" => $bRedirect ? GetMessage("SEC_PANEL_ANTIFISHING_VALUE_ON") : GetMessage("SEC_PANEL_ANTIFISHING_VALUE_OFF"), "KPI_RECOMMENDATION" => $bRedirect ? '&nbsp;' : ($USER->CanDoOperation('security_redirect_settings_write') ? '<a href="security_redirect.php?lang=' . LANGUAGE_ID . '&amp;return_url=' . urlencode('security_panel.php?lang=' . LANGUAGE_ID) . '">' . GetMessage("SEC_PANEL_ANTIFISHING_RECOMMENDATION") . '</a>' : GetMessage("SEC_PANEL_ANTIFISHING_RECOMMENDATION")));
$bOTP = CSecurityUser::isActive();
                $message = new CAdminMessage(GetMessage("SEC_IP_EDIT_SAVE_ERROR"), $e);
            }
            $bVarsFromForm = true;
        }
    }
}
ClearVars("str_");
$str_ACTIVE = "Y";
$str_ADMIN_SECTION = "Y";
$str_SITE_ID = "";
$str_SORT = "500";
$str_NAME = "";
$str_ACTIVE_FROM = "";
$str_ACTIVE_TO = "";
if ($ID > 0) {
    $rs = CSecurityIPRule::GetList(array(), array("=ID" => $ID), array());
    if (!$rs->ExtractFields("str_")) {
        $ID = 0;
    }
}
if ($bVarsFromForm) {
    $DB->InitTableVarsForEdit("b_sec_iprule", "", "str_");
}
$APPLICATION->SetTitle($ID > 0 ? GetMessage("SEC_IP_EDIT_EDIT_TITLE") : GetMessage("SEC_IP_EDIT_ADD_TITLE"));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$aMenu = array(array("TEXT" => GetMessage("SEC_IP_EDIT_MENU_LIST"), "TITLE" => GetMessage("SEC_IP_EDIT_MENU_LIST_TITLE"), "LINK" => "security_iprule_list.php?lang=" . LANG, "ICON" => "btn_list"));
if ($ID > 0) {
    $aMenu[] = array("SEPARATOR" => "Y");
    $aMenu[] = array("TEXT" => GetMessage("SEC_IP_EDIT_MENU_ADD"), "TITLE" => GetMessage("SEC_IP_EDIT_MENU_ADD_TITLE"), "LINK" => "security_iprule_edit.php?lang=" . LANG, "ICON" => "btn_new");
    $aMenu[] = array("TEXT" => GetMessage("SEC_IP_EDIT_MENU_DELETE"), "TITLE" => GetMessage("SEC_IP_EDIT_MENU_DELETE_TITLE"), "LINK" => "javascript:if(confirm('" . GetMessage("SEC_IP_EDIT_MENU_DELETE_CONF") . "'))window.location='security_iprule_list.php?ID=" . $ID . "&action=delete&lang=" . LANG . "&" . bitrix_sessid_get() . "';", "ICON" => "btn_delete");
}
Exemple #4
0
 function CleanUpAgent()
 {
     $agentName = "CSecurityIPRule::CleanUpAgent();";
     $cleanupDays = 2;
     $activeTo = ConvertTimeStamp(time() - $cleanupDays * 24 * 60 * 60, "FULL");
     if (!$activeTo) {
         return $agentName;
     }
     $rs = CSecurityIPRule::GetList(array("ID"), array("=RULE_TYPE" => "A", "<=ACTIVE_TO" => $activeTo), array("ID" => "ASC"));
     while ($ar = $rs->Fetch()) {
         CSecurityIPRule::Delete($ar["ID"]);
     }
     return $agentName;
 }
Exemple #5
0
 function CleanUpAgent()
 {
     $cleanup_days = 2;
     $rs = CSecurityIPRule::GetList(array("ID"), array("=RULE_TYPE" => "A", "<=ACTIVE_TO" => ConvertTimeStamp(time() - $cleanup_days * 24 * 60 * 60, "FULL")), array("ID" => "ASC"));
     while ($ar = $rs->Fetch()) {
         CSecurityIPRule::Delete($ar["ID"]);
     }
     return "CSecurityIPRule::CleanUpAgent();";
 }