isAdmin()) $APPLICATION->AuthForm(Loc::getMessage('ACCESS_DENIED')); $tabs = array( array( 'DIV' => 'main', 'TAB' => Loc::getMessage('SECURITY_HOSTS_MAIN_TAB'), 'ICON' => 'main_user_edit', 'TITLE' => Loc::getMessage('SECURITY_HOSTS_MAIN_TAB_TITLE'), ), ); $tabControl = new \CAdminTabControl('tabControl', $tabs, true, true); $bVarsFromForm = false; $hosts = new Security\HostRestriction(); /** @var $request Main\HttpRequest */ $request = Main\Context::getCurrent()->getRequest(); $returnUrlQuery = $request['return_url']? '&return_url='.urlencode($request['return_url']): ''; $errorMessage = null; $properties = $hosts->getProperties(); if($request->isPost() && $request['save'].$request['apply'] && check_bitrix_sessid()) { try { $properties = $request->getPost('properties'); if (isset($properties['active']) && $properties['active'] === 'Y') $properties['active'] = true; else $properties['active'] = false; if (isset($properties['logging']) && $properties['logging'] === 'Y') $properties['logging'] = true; else $properties['logging'] = false; if (!isset($properties['action']) || !$properties['action']) throw new Security\LogicException('Action not presents', 'SECURITY_HOST_EMPTY_ACTION'); if (!isset($properties['hosts']) || !trim($properties['hosts'])) throw new Security\LogicException('Hosts not presents', 'SECURITY_HOST_EMPTY_HOSTS'); $hosts ->setHosts($properties['hosts']) ->setAction($properties['action'], $properties['action_options']?:array()) ->setLogging($properties['logging']) ->setActive($properties['active']) ->save(); if($request['save'] && $request['return_url'] != '') LocalRedirect($request['return_url']); LocalRedirect('/bitrix/admin/security_hosts.php?lang='.LANGUAGE_ID.$returnUrlQuery.'&'.$tabControl->ActiveTabParam()); } catch (Security\LogicException $e) { $errorMessage = $e->getLocMessage(); } catch (Main\ArgumentException $e) { $errorMessage = Loc::getMessage('SECURITY_HOSTS_SAVE_UNKNOWN_ERROR', array( '#CODE#' => $e->getMessage() )); } } if ($hosts->getActive()) { $messageType = 'OK'; $messageText = Loc::getMessage('SECURITY_HOSTS_ON'); } else { $messageType = 'ERROR'; $messageText = Loc::getMessage('SECURITY_HOSTS_OFF'); } $APPLICATION->SetTitle(Loc::getMessage('SECURITY_HOSTS_TITLE')); require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_after.php'); \CAdminMessage::ShowMessage(array( 'MESSAGE' => $messageText, 'TYPE' => $messageType ) ); if (!is_null($errorMessage)) \CAdminMessage::ShowMessage(array( 'MESSAGE' => Loc::getMessage('SECURITY_HOSTS_SAVE_ERROR'), 'DETAILS' => $errorMessage, 'TYPE' => 'ERROR' ) ); ?>