/// <summary> /// 绑定隐藏控件域(防止提交垃圾) /// </summary> public void BindHiddenField() { if (Settings_Hiddenfields_Enable) { //生成认证密钥10位 String VerifyString = WebHelper.leftx(Guid.NewGuid().ToString("N"), Settings_Hiddenfields_VerifyStringLength); String VerifyEncrypt = CryptionHelper.EncryptString1(VerifyString, Settings_Hiddenfields_EncryptionKey); // CryptionHelper.EncryptString(VerifyString, Settings_Hiddenfields_EncryptionKey); hfVerifyString.Value = VerifyString; hfVerifyEncrypt.Value = VerifyEncrypt; } }
/// <summary> /// 下载表单文件 /// </summary> public void DownLoadFormFile() { bool LoginUserDownload = ViewSettingT <bool>("PowerForms_LoginUserDownload", false); if ((LoginUserDownload && UserInfo.UserID > 0) || !LoginUserDownload) { String filepath = WebHelper.GetStringParam(Request, "file", ""); if (!String.IsNullOrEmpty(filepath)) { try { filepath = CryptionHelper.DecryptString(CryptionHelper.Base64Decode(filepath)); if (!String.IsNullOrEmpty(filepath)) { String FileUrl = MapPath(String.Format("~/Portals/{0}/PowerForms/{1}/{2}", PortalId, ModuleId, filepath)); if (File.Exists(FileUrl)) { Response.Write(" <script>window.opener=null;window.close(); </script>"); FileSystemUtils.DownloadFile(FileUrl, Path.GetFileName(FileUrl)); } } } catch { } } } else { String file = WebHelper.GetStringParam(Request, "file", ""); String RedirectFile = String.Format("{0}Resource_Service.aspx?Token=downloadformfile&PortalId={1}&ModuleId={2}&file={3}", ModulePath, PortalId, ModuleId, Server.UrlEncode(file)); Response.Redirect(Globals.NavigateURL(PortalSettings.LoginTabId, "Login", "returnurl=" + Server.UrlEncode(RedirectFile)), false); //String file = WebHelper.GetStringParam(Request, "file", ""); //String RedirectFile = Globals.NavigateURL("", "a=b","Token=abc","bb=cc", "PortalId="+ PortalId.ToString(), "TabId="+ TabId.ToString(), "ModuleId="+ ModuleId.ToString(), "file="+ Server.UrlEncode(file));// String.Format("{0}Resource_Service.aspx?Token=RedirectFormFile&PortalId={1}&ModuleId={2}&file={3}", ModulePath, PortalId, ModuleId, Server.UrlEncode(file)); //Response.Redirect(Globals.NavigateURL(PortalSettings.LoginTabId, "Login", "returnurl=" + Server.UrlEncode(RedirectFile)),false); } }
/// <summary> /// 验证隐藏域 /// </summary> /// <returns></returns> public Boolean VerificationHiddenfields(ref Boolean RepeatSubmitted) { Boolean HiddenfieldsVerify = true; String VerifyEncrypt = WebHelper.GetStringParam(Request, hfVerifyEncrypt.UniqueID, "", false); String VerifyString = WebHelper.GetStringParam(Request, hfVerifyString.UniqueID, "", false); if (!String.IsNullOrEmpty(VerifyEncrypt) && !String.IsNullOrEmpty(VerifyString)) { try { String DecryptString = CryptionHelper.DecryptString1(VerifyEncrypt, Settings_Hiddenfields_EncryptionKey);//CryptionHelper.DecryptString(VerifyEncrypt, Settings_Hiddenfields_EncryptionKey); if (!String.IsNullOrEmpty(DecryptString) && VerifyString == DecryptString) { //查询该信息是否为重复提交的 QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.VerifyString, VerifyString, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.LastTime, xUserTime.UtcTime().AddMinutes(-Settings_Hiddenfields_VerifyIntervalTime), SearchType.GtEqual)); if (DNNGo_PowerForms_Content.FindCount(qp) > 0) { RepeatSubmitted = false; } } else { HiddenfieldsVerify = false; } } catch { HiddenfieldsVerify = false; } } else { HiddenfieldsVerify = false; } return(HiddenfieldsVerify); }