Exemplo n.º 1
1
 public static function activate()
 {
     COption::SetOptionString("security", "session", "Y");
     CSecuritySession::Init();
     CAgent::RemoveAgent(self::GC_AGENT_NAME, "security");
     CAgent::Add(array("NAME" => self::GC_AGENT_NAME, "MODULE_ID" => "security", "ACTIVE" => "Y", "AGENT_INTERVAL" => 1800, "IS_PERIOD" => "N"));
 }
Exemplo n.º 2
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);
         CSecurityAntiVirus::SetActive(true);
         return true;
     }
 }
Exemplo n.º 3
0
 function InstallDB($arParams = array())
 {
     global $DB, $DBType, $APPLICATION;
     $this->errors = false;
     // Database tables creation
     if (!$DB->Query("SELECT 'x' FROM b_list_rubric WHERE 1=0", true)) {
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/subscribe/install/db/" . $DBType . "/install.sql");
     }
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("<br>", $this->errors));
         return false;
     } else {
         RegisterModule("subscribe");
         CModule::IncludeModule("subscribe");
         RegisterModuleDependences("main", "OnBeforeLangDelete", "subscribe", "CRubric", "OnBeforeLangDelete");
         RegisterModuleDependences("main", "OnUserDelete", "subscribe", "CSubscription", "OnUserDelete");
         RegisterModuleDependences("main", "OnUserLogout", "subscribe", "CSubscription", "OnUserLogout");
         RegisterModuleDependences("main", "OnGroupDelete", "subscribe", "CPosting", "OnGroupDelete");
         //agents
         CAgent::RemoveAgent("CSubscription::CleanUp();", "subscribe");
         CTimeZone::Disable();
         CAgent::Add(array("NAME" => "CSubscription::CleanUp();", "MODULE_ID" => "subscribe", "ACTIVE" => "Y", "NEXT_EXEC" => date("d.m.Y H:i:s", mktime(3, 0, 0, date("m"), date("j") + 1, date("Y"))), "AGENT_INTERVAL" => 86400, "IS_PERIOD" => "Y"));
         CTimeZone::Enable();
         return true;
     }
 }
Exemplo n.º 4
0
 function AddAgent($name, $module = "", $period = "N", $interval = 86400, $datecheck = "", $active = "Y", $next_exec = "", $sort = 100, $user_id = false)
 {
     global $DB, $APPLICATION;
     $z = $DB->Query("\n\t\t\tSELECT 'x'\n\t\t\tFROM b_agent\n\t\t\tWHERE NAME = '" . $DB->ForSql($name, 2000) . "'\n\t\t\tAND USER_ID" . ($user_id ? " = " . intval($user_id) : " IS NULL"));
     if (!$z->Fetch()) {
         $arFields = array("MODULE_ID" => $module, "SORT" => $sort, "NAME" => $name, "ACTIVE" => $active, "AGENT_INTERVAL" => $interval, "IS_PERIOD" => $period, "USER_ID" => $user_id);
         if (strlen($next_exec) > 0) {
             $arFields["NEXT_EXEC"] = $next_exec;
         }
         $ID = CAgent::Add($arFields);
         return $ID;
     } else {
         $e = new CAdminException(array(array("id" => "agent_exist", "text" => GetMessage("MAIN_AGENT_ERROR_EXIST"))));
         $APPLICATION->throwException($e);
         return false;
     }
 }
Exemplo n.º 5
0
 function AddAgent($name, $module = "", $period = "N", $interval = 86400, $datecheck = "", $active = "Y", $next_exec = "", $sort = 100, $user_id = false, $existError = true)
 {
     global $DB, $APPLICATION;
     $z = $DB->Query("\n\t\t\tSELECT ID\n\t\t\tFROM b_agent\n\t\t\tWHERE NAME = '" . $DB->ForSql($name, 2000) . "'\n\t\t\tAND USER_ID" . ($user_id ? " = " . (int) $user_id : " IS NULL"));
     if (!($agent = $z->Fetch())) {
         $arFields = array("MODULE_ID" => $module, "SORT" => $sort, "NAME" => $name, "ACTIVE" => $active, "AGENT_INTERVAL" => $interval, "IS_PERIOD" => $period, "USER_ID" => $user_id);
         $next_exec = (string) $next_exec;
         if ($next_exec != '') {
             $arFields["NEXT_EXEC"] = $next_exec;
         }
         $ID = CAgent::Add($arFields);
         return $ID;
     } else {
         if (!$existError) {
             return $agent['ID'];
         }
         $e = new CAdminException(array(array("id" => "agent_exist", "text" => $user_id ? Loc::getMessage("MAIN_AGENT_ERROR_EXIST_FOR_USER", array('#AGENT#' => $name, '#USER_ID#' => $user_id)) : Loc::getMessage("MAIN_AGENT_ERROR_EXIST_EXT", array('#AGENT#' => $name)))));
         $APPLICATION->throwException($e);
         return false;
     }
 }
Exemplo n.º 6
0
if (!$USER->IsAdmin()) {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
if (!CModule::IncludeModule('security')) {
    require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
    ShowError(GetMessage("CLU_SESSION_NO_SECURITY"));
    require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
}
$aTabs = array(array("DIV" => "savedb", "TAB" => GetMessage("CLU_SESSION_SAVEDB_TAB"), "ICON" => "main_user_edit", "TITLE" => GetMessage("CLU_SESSION_SAVEDB_TAB_TITLE")));
$tabControl = new CAdminTabControl("tabControl", $aTabs);
if ($REQUEST_METHOD == "POST" && check_bitrix_sessid() && ($save != "" || $apply != "" || $db_session_on != "" || $db_session_off != "")) {
    if (array_key_exists("db_session_on", $_POST)) {
        COption::SetOptionString("security", "session", "Y");
        CSecuritySession::Init();
        CAgent::RemoveAgent("CSecuritySession::CleanUpAgent();", "security");
        CAgent::Add(array("NAME" => "CSecuritySession::CleanUpAgent();", "MODULE_ID" => "security", "ACTIVE" => "Y", "AGENT_INTERVAL" => 1800, "IS_PERIOD" => "N"));
    } elseif (array_key_exists("db_session_off", $_POST)) {
        COption::SetOptionString("security", "session", "N");
        CAgent::RemoveAgent("CSecuritySession::CleanUpAgent();", "security");
    }
    if ($save != "" && $_GET["return_url"] != "") {
        LocalRedirect($_GET["return_url"]);
    }
    LocalRedirect("/bitrix/admin/cluster_session.php?lang=" . LANGUAGE_ID . ($return_url ? "&return_url=" . urlencode($_GET["return_url"]) : "") . "&" . $tabControl->ActiveTabParam());
}
$APPLICATION->SetTitle(GetMessage("CLU_SESSION_TITLE"));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
?>

<form method="POST" action="cluster_session.php?lang=<?php 
echo LANGUAGE_ID;
Exemplo n.º 7
0
    $arr = $res->ExtractFields("a_");
}
$APPLICATION->SetTitle($ID <= 0 ? GetMessage("MAIN_AGENT_NEW_PAGE_TITLE") : str_replace("#ID#", " {$ID}", GetMessage("MAIN_AGENT_EDIT_PAGE_TITLE")));
$sTableID = "tbl_agent_edit";
$aTabs = array(array("DIV" => "tab1", "TAB" => GetMessage("MAIN_AGENT_TAB"), "ICON" => "main_user_edit", "TITLE" => GetMessage("MAIN_AGENT_TAB_TITLE")));
$editTab = new CAdminTabControl("editTab", $aTabs);
$APPLICATION->ResetException();
if ($REQUEST_METHOD == "POST" && (strlen($save) > 0 || strlen($apply) > 0) && $isAdmin && check_bitrix_sessid()) {
    $arFields = array("NAME" => $NAME, "MODULE_ID" => $MODULE_ID, "ACTIVE" => $ACTIVE, "SORT" => $SORT, "IS_PERIOD" => $IS_PERIOD, "AGENT_INTERVAL" => $AGENT_INTERVAL, "NEXT_EXEC" => $NEXT_EXEC, "USER_ID" => false);
    if (intval($USER_ID) > 0) {
        $arFields["USER_ID"] = $USER_ID;
    }
    if ($ID > 0) {
        $res = CAgent::Update($ID, $arFields);
    } else {
        $ID = CAgent::Add($arFields);
        $res = $ID > 0;
    }
    if ($res) {
        if (strlen($save) > 0) {
            LocalRedirect("/bitrix/admin/agent_list.php");
        } elseif (strlen($apply) > 0) {
            LocalRedirect("/bitrix/admin/agent_edit.php?&ID=" . $ID . "&" . $editTab->ActiveTabParam());
        }
    }
}
require $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/prolog_admin_after.php";
$aMenu = array(array("TEXT" => GetMessage("MAIN_AGENT_RECORD_LIST"), "LINK" => "/bitrix/admin/agent_list.php?lang=" . LANG, "ICON" => "btn_list", "TITLE" => GetMessage("MAIN_AGENT_RECORD_LIST_TITLE")));
if ($ID > 0) {
    $aMenu[] = array("SEPARATOR" => "Y");
    $aMenu[] = array("TEXT" => GetMessage("MAIN_AGENT_NEW_RECORD"), "LINK" => "/bitrix/admin/agent_edit.php?lang=" . LANGUAGE_ID, "ICON" => "btn_new", "TITLE" => GetMessage("MAIN_AGENT_NEW_RECORD_TITLE"));
Exemplo n.º 8
0
 /**
  * @param bool $pActive
  */
 public static function setActive($pActive = false)
 {
     $otpRecheckAgent = 'Bitrix\\Security\\Mfa\\OtpEvents::onRecheckDeactivate();';
     if ($pActive) {
         if (!CSecurityUser::isActive()) {
             RegisterModuleDependences("main", "OnBeforeUserLogin", "security", "CSecurityUser", "OnBeforeUserLogin", "100");
             RegisterModuleDependences("main", "OnAfterUserLogout", "security", "CSecurityUser", "OnAfterUserLogout", "100");
             CAgent::RemoveAgent($otpRecheckAgent, "security");
             CAgent::Add(array("NAME" => $otpRecheckAgent, "MODULE_ID" => "security", "ACTIVE" => "Y", "AGENT_INTERVAL" => 3600, "IS_PERIOD" => "N"));
             $f = fopen($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/security/options_user_settings.php", "w");
             fwrite($f, "<?include(\$_SERVER[\"DOCUMENT_ROOT\"].\"/bitrix/modules/security/options_user_settings_1.php\");?>");
             fclose($f);
             COption::SetOptionString('security', 'otp_enabled', 'Y');
         }
     } else {
         if (CSecurityUser::isActive()) {
             UnRegisterModuleDependences("main", "OnBeforeUserLogin", "security", "CSecurityUser", "OnBeforeUserLogin");
             UnRegisterModuleDependences("main", "OnAfterUserLogout", "security", "CSecurityUser", "OnAfterUserLogout");
             CAgent::RemoveAgent($otpRecheckAgent, "security");
             unlink($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/security/options_user_settings.php");
             COption::SetOptionString('security', 'otp_enabled', 'N');
         }
     }
 }