Example #1
0
 function InstallDB($arParams = array())
 {
     global $DB, $DBType, $APPLICATION;
     $this->errors = false;
     // Database tables creation
     if (!$DB->Query("SELECT 'x' FROM b_sec_iprule WHERE 1=0", true)) {
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/security/install/db/" . strtolower($DB->type) . "/install.sql");
     }
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("<br>", $this->errors));
         return false;
     } else {
         $this->InstallTasks();
         RegisterModule("security");
         RegisterModuleDependences("main", "OnUserDelete", "security", "CSecurityUser", "OnUserDelete");
         RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "security", "CSecurityFilter", "GetAuditTypes");
         RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "security", "CSecurityAntiVirus", "GetAuditTypes");
         RegisterModuleDependences("main", "OnAdminInformerInsertItems", "security", "CSecurityFilter", "OnAdminInformerInsertItems");
         RegisterModuleDependences("main", "OnAdminInformerInsertItems", "security", "CSecuritySiteChecker", "OnAdminInformerInsertItems");
         CModule::IncludeModule("security");
         //agents
         CAgent::RemoveAgent("CSecuritySession::CleanUpAgent();", "security");
         CAgent::Add(array("NAME" => "CSecuritySession::CleanUpAgent();", "MODULE_ID" => "security", "ACTIVE" => "Y", "AGENT_INTERVAL" => 1800, "IS_PERIOD" => "N"));
         CAgent::RemoveAgent("CSecurityIPRule::CleanUpAgent();", "security");
         CAgent::Add(array("NAME" => "CSecurityIPRule::CleanUpAgent();", "MODULE_ID" => "security", "ACTIVE" => "Y", "AGENT_INTERVAL" => 3600, "IS_PERIOD" => "N"));
         if (!COption::GetOptionString("security", "ipcheck_disable_file")) {
             COption::SetOptionString("security", "ipcheck_disable_file", "/bitrix/modules/ipcheck_disable_" . md5(mt_rand()));
         }
         CAgent::RemoveAgent("CSecurityFilter::ClearTmpFiles();", "security");
         CSecurityFilter::SetActive(true);
         CSecurityRedirect::SetActive(true);
         return true;
     }
 }
IncludeModuleLangFile(__FILE__);
/**
 * @global CUser $USER
 * @global CMain $APPLICATION
 **/
$canRead = $USER->CanDoOperation('security_redirect_settings_read');
$canWrite = $USER->CanDoOperation('security_redirect_settings_write');
if (!$canRead && !$canWrite) {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
$aTabs = array(array("DIV" => "main", "TAB" => GetMessage("SEC_REDIRECT_MAIN_TAB"), "ICON" => "main_user_edit", "TITLE" => GetMessage("SEC_REDIRECT_MAIN_TAB_TITLE")), array("DIV" => "parameters", "TAB" => GetMessage("SEC_REDIRECT_PARAMETERS_TAB"), "ICON" => "main_user_edit", "TITLE" => GetMessage("SEC_REDIRECT_PARAMETERS_TAB_TITLE")));
$tabControl = new CAdminTabControl("tabControl", $aTabs, true, true);
$returnUrl = $_GET["return_url"] ? "&return_url=" . urlencode($_GET["return_url"]) : "";
if ($_SERVER['REQUEST_METHOD'] == "POST" && $_REQUEST['save'] . $_REQUEST['apply'] . $_REQUEST['redirect_button'] != "" && $canWrite && check_bitrix_sessid()) {
    if ($_REQUEST['redirect_button'] != "") {
        CSecurityRedirect::SetActive($_POST["redirect_active"] === "Y");
    }
    COption::SetOptionString("security", "redirect_log", $_POST["redirect_log"] === "Y" ? "Y" : "N");
    COption::SetOptionString("security", "redirect_referer_check", $_POST["redirect_referer_check"] === "Y" ? "Y" : "N");
    COption::SetOptionString("security", "redirect_referer_site_check", $_POST["redirect_referer_site_check"] === "Y" ? "Y" : "N");
    COption::SetOptionString("security", "redirect_href_sign", $_POST["redirect_href_sign"] === "Y" ? "Y" : "N");
    if ($_POST["redirect_action"] === "show_message") {
        COption::SetOptionString("security", "redirect_action", "show_message");
        COption::RemoveOption("security", "redirect_message_warning");
        $l = CLanguage::GetList($lby = "sort", $lorder = "asc");
        while ($ar = $l->Fetch()) {
            $mess = trim($_POST["redirect_message_warning_" . $ar["LID"]]);
            if (strlen($mess) > 0) {
                COption::SetOptionString("security", "redirect_message_warning_" . $ar["LID"], $mess);
            } else {
                COption::RemoveOption("security", "redirect_message_warning_" . $ar["LID"]);