PageRenderTime 34ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/security/admin/security_antivirus.php

https://gitlab.com/alexprowars/bitrix
PHP | 235 lines | 212 code | 19 blank | 4 comment | 24 complexity | e926c2734b318d7202998f9970042bed MD5 | raw file
  1. <?
  2. define("ADMIN_MODULE_NAME", "security");
  3. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
  4. CModule::IncludeModule('security');
  5. IncludeModuleLangFile(__FILE__);
  6. /**
  7. * @global CUser $USER
  8. * @global CMain $APPLICATION
  9. **/
  10. $canRead = $USER->CanDoOperation('security_antivirus_settings_read');
  11. $canWrite = $USER->CanDoOperation('security_antivirus_settings_write');
  12. if(!$canRead && !$canWrite)
  13. $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
  14. $rsSecurityWhiteList = CSecurityAntiVirus::GetWhiteList();
  15. if($rsSecurityWhiteList->Fetch())
  16. $bSecurityWhiteList = true;
  17. else
  18. $bSecurityWhiteList = false;
  19. $aTabs = array(
  20. array(
  21. "DIV" => "main",
  22. "TAB" => GetMessage("SEC_ANTIVIRUS_MAIN_TAB"),
  23. "ICON"=>"main_user_edit",
  24. "TITLE"=>GetMessage("SEC_ANTIVIRUS_MAIN_TAB_TITLE"),
  25. ),
  26. array(
  27. "DIV" => "params",
  28. "TAB" => GetMessage("SEC_ANTIVIRUS_PARAMETERS_TAB"),
  29. "ICON"=>"main_user_edit",
  30. "TITLE"=>GetMessage("SEC_ANTIVIRUS_PARAMETERS_TAB_TITLE"),
  31. ),
  32. array(
  33. "DIV" => "exceptions",
  34. "TAB" => $bSecurityWhiteList? GetMessage("SEC_ANTIVIRUS_WHITE_LIST_SET_TAB"): GetMessage("SEC_ANTIVIRUS_WHITE_LIST_TAB"),
  35. "ICON"=>"main_user_edit",
  36. "TITLE"=>GetMessage("SEC_ANTIVIRUS_WHITE_LIST_TAB_TITLE"),
  37. ),
  38. );
  39. $tabControl = new CAdminTabControl("tabControl", $aTabs, true, true);
  40. $bVarsFromForm = false;
  41. $returnUrl = $_GET["return_url"]? "&return_url=".urlencode($_GET["return_url"]): "";
  42. if(
  43. $_SERVER["REQUEST_METHOD"] == "POST"
  44. && $_REQUEST["save"].$_REQUEST["apply"].$_REQUEST["antivirus_b"] !=""
  45. && $canWrite
  46. && check_bitrix_sessid()
  47. )
  48. {
  49. if($_REQUEST["antivirus_b"]!="")
  50. CSecurityAntiVirus::SetActive($_POST["antivirus_active"]==="Y");
  51. $antivirus_timeout = intval($_POST["antivirus_timeout"]);
  52. if($antivirus_timeout <= 0)
  53. $antivirus_timeout = 1;
  54. COption::SetOptionInt("security", "antivirus_timeout", $antivirus_timeout);
  55. if($_POST["antivirus_action"]==="notify_only")
  56. COption::SetOptionString("security", "antivirus_action", "notify_only");
  57. else
  58. COption::SetOptionString("security", "antivirus_action", "replace");
  59. CSecurityAntiVirus::UpdateWhiteList($_POST["WHITE_LIST"]);
  60. if($_REQUEST["save"] != "" && $_GET["return_url"]!="")
  61. LocalRedirect($_GET["return_url"]);
  62. else
  63. LocalRedirect("/bitrix/admin/security_antivirus.php?lang=".LANGUAGE_ID.$returnUrl."&".$tabControl->ActiveTabParam());
  64. }
  65. $messageDetails = "";
  66. if (CSecurityAntiVirus::IsActive())
  67. {
  68. $messageType = "OK";
  69. $messageText = GetMessage("SEC_ANTIVIRUS_ON");
  70. if($bSecurityWhiteList || COption::GetOptionString("security", "antivirus_action") == "notify_only")
  71. $messageDetails = "<span style=\"font-style: italic;\">".GetMessage("SEC_ANTIVIRUS_WARNING")."</span>";
  72. }
  73. else
  74. {
  75. $messageType = "ERROR";
  76. $messageText = GetMessage("SEC_ANTIVIRUS_OFF");
  77. }
  78. $warningMessage = "";
  79. if(!defined("BX_SECURITY_AV_STARTED"))
  80. {
  81. if(preg_match("/cgi/i", php_sapi_name()))
  82. $warningMessage = GetMessage("SEC_ANTIVIRUS_PREBODY_NOTFOUND_CGI", array("#PATH#" => $_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/security/tools/start.php"));
  83. else
  84. $warningMessage = GetMessage("SEC_ANTIVIRUS_PREBODY_NOTFOUND", array("#PATH#" => $_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/security/tools/start.php"));
  85. }
  86. $APPLICATION->SetTitle(GetMessage("SEC_ANTIVIRUS_TITLE"));
  87. CUtil::InitJSCore();
  88. $APPLICATION->AddHeadScript('/bitrix/js/security/admin/interface.js');
  89. require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
  90. CAdminMessage::ShowMessage(array(
  91. "MESSAGE" => $messageText,
  92. "TYPE" => $messageType,
  93. "DETAILS" => $messageDetails,
  94. "HTML" => true
  95. ));
  96. ?>
  97. <form method="POST" action="security_antivirus.php?lang=<?=LANGUAGE_ID?><?=htmlspecialcharsbx($returnUrl)?>" enctype="multipart/form-data" name="editform">
  98. <?
  99. $tabControl->Begin();
  100. ?>
  101. <?
  102. $tabControl->BeginNextTab();
  103. ?>
  104. <?if(CSecurityAntiVirus::IsActive()):?>
  105. <tr>
  106. <td colspan="2" align="left">
  107. <input type="hidden" name="antivirus_active" value="N">
  108. <input type="submit" name="antivirus_b" value="<?echo GetMessage("SEC_ANTIVIRUS_BUTTON_OFF")?>"<?if(!$canWrite) echo " disabled"?>>
  109. </td>
  110. </tr>
  111. <?else:?>
  112. <tr>
  113. <td colspan="2" align="left">
  114. <input type="hidden" name="antivirus_active" value="Y">
  115. <input type="submit" name="antivirus_b" value="<?echo GetMessage("SEC_ANTIVIRUS_BUTTON_ON")?>"<?if(!$canWrite) echo " disabled"?> class="adm-btn-save">
  116. </td>
  117. </tr>
  118. <?endif?>
  119. <?if($warningMessage <> ''):?>
  120. <tr>
  121. <td colspan="2" align="left">
  122. <?
  123. CAdminMessage::ShowMessage(array(
  124. "TYPE"=>"ERROR",
  125. "DETAILS"=>$warningMessage,
  126. "HTML"=>true
  127. ));
  128. ?>
  129. </td>
  130. </tr>
  131. <?endif;?>
  132. <tr>
  133. <td colspan="2">
  134. <?echo BeginNote();?>
  135. <?echo GetMessage("SEC_ANTIVIRUS_NOTE")?>
  136. <p><i><?echo GetMessage("SEC_ANTIVIRUS_LEVEL")?></i></p>
  137. <?echo EndNote(); ?>
  138. </td>
  139. </tr>
  140. <?
  141. $tabControl->BeginNextTab();
  142. ?>
  143. <tr>
  144. <td class="adm-detail-valign-top" width="40%"><?echo GetMessage("SEC_ANTIVIRUS_ACTION")?>:</td>
  145. <td width="60%">
  146. <label><input type="radio" name="antivirus_action" value="replace" <?if(COption::GetOptionString("security", "antivirus_action") != "notify_only") echo "checked";?>><?echo GetMessage("SEC_ANTIVIRUS_ACTION_REPLACE")?></span></label><br>
  147. <label><input type="radio" name="antivirus_action" value="notify_only" <?if(COption::GetOptionString("security", "antivirus_action") == "notify_only") echo "checked";?>><?echo GetMessage("SEC_ANTIVIRUS_ACTION_NOTIFY_ONLY")?></label><br>
  148. </td>
  149. </tr>
  150. <tr>
  151. <td><label for="antivirus_timeout"><?echo GetMessage("SEC_ANTIVIRUS_TIMEOUT")?></label>:</td>
  152. <td>
  153. <input type="text" size="4" name="antivirus_timeout" value="<?echo COption::GetOptionInt("security", "antivirus_timeout")?>">
  154. </td>
  155. </tr>
  156. <?
  157. $tabControl->BeginNextTab();
  158. $arWhiteList = array();
  159. if($bVarsFromForm)
  160. {
  161. if(is_array($_POST["WHITE_LIST"]))
  162. foreach($_POST["WHITE_LIST"] as $i => $v)
  163. $arWhiteList[] = htmlspecialcharsbx($v);
  164. }
  165. else
  166. {
  167. $rs = CSecurityAntiVirus::GetWhiteList();
  168. while($ar = $rs->Fetch())
  169. $arWhiteList[] = htmlspecialcharsbx($ar["WHITE_SUBSTR"]);
  170. }
  171. ?>
  172. <tr>
  173. <td class="adm-detail-valign-top" width="40%" style="padding-top:12px;"><?echo GetMessage("SEC_ANTIVIRUS_WHITE_LIST")?></td>
  174. <td width="60%">
  175. <table cellpadding="0" cellspacing="0" border="0" width="100%" id="tb_WHITE_LIST">
  176. <?foreach($arWhiteList as $i => $white_substr):?>
  177. <tr><td nowrap style="padding-bottom: 3px;">
  178. <input type="text" size="45" name="WHITE_LIST[<?echo $i?>]" value="<?echo $white_substr?>">
  179. </td></tr>
  180. <?endforeach;?>
  181. <?if(!$bVarsFromForm):?>
  182. <tr class="security-addable-row"><td nowrap style="padding-bottom: 3px;">
  183. <input type="text" size="45" name="WHITE_LIST[n0]" value="">
  184. </td></tr>
  185. <?endif;?>
  186. <tr><td>
  187. <br><input type="button" id="add-button" value="<?echo GetMessage("SEC_ANTIVIRUS_ADD")?>">
  188. </td></tr>
  189. </table>
  190. </td>
  191. </tr>
  192. <script id="security-interface-settings" type="application/json">
  193. {
  194. "addableRows": [{
  195. "tableId": "tb_WHITE_LIST",
  196. "buttonId": "add-button"
  197. }]
  198. }
  199. </script>
  200. <?
  201. $tabControl->Buttons(
  202. array(
  203. "disabled"=>(!$canWrite),
  204. "back_url"=>$_GET["return_url"]? $_GET["return_url"]: "security_iprule_list.php?lang=".LANG,
  205. )
  206. );
  207. ?>
  208. <?echo bitrix_sessid_post();?>
  209. <input type="hidden" name="lang" value="<?echo LANG?>">
  210. <?
  211. $tabControl->End();
  212. ?>
  213. </form>
  214. <?
  215. require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php");
  216. ?>