public bool AllowEditUserInfo(int uid, bool redirect) { #region 是否允许编辑用户信息 if ((BaseConfigs.GetBaseConfig().Founderuid == uid) && (uid == this.userid)) { return(true); } else { if (BaseConfigs.GetBaseConfig().Founderuid != uid) //当要编辑的用户信息不是创建人的信息时 { return(true); } else { if (redirect) { base.RegisterStartupScript("", "<script>alert('您要编辑信息是论坛创始人信息,请您以创始人身份登陆后台才能修改!');</script>"); } return(false); } } #endregion }
/// <summary> /// 自动检查当前程序的目录状态并保存 /// </summary> /// <param name="forumPath"></param> public static void SaveDntConfigForumPath() { HttpRequest request = HttpContext.Current.Request; string forumPath = request.Url.ToString().Replace("http://" + request.Url.Authority, ""); if (forumPath.IndexOf("install") < 0) { return; } forumPath = forumPath.Substring(0, forumPath.IndexOf("install")); BaseConfigInfo baseConfig = BaseConfigs.GetBaseConfig(); if (baseConfig.Forumpath.Trim() != forumPath) { baseConfig.Forumpath = forumPath; string dntPath = Utils.GetMapPath("~/DNT.config"); if (!Utils.FileExists(dntPath)) { dntPath = Utils.GetMapPath("/DNT.config"); } SerializationHelper.Save(baseConfig, dntPath); BaseConfigs.ResetRealConfig(); Utils.RestartIISProcess(); } }
/// <summary> /// 获得勋章列表 /// </summary> /// <returns>获得勋章列表</returns> public static DataTable GetMedalsList() { Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService(); DataTable dt = cache.RetrieveObject("/UI/MedalsList") as DataTable; if (dt != null) { return(dt); } dt = DatabaseProvider.GetInstance().GetMedalsList(); string forumpath = BaseConfigs.GetBaseConfig().Forumpath; foreach (DataRow dr in dt.Rows) { if (dr["available"].ToString() == "1") { if (dr["image"].ToString().Trim() != "") { dr["image"] = "<img border=\"0\" src=\"" + forumpath + "images/medals/" + dr["image"] + "\" alt=\"" + dr["name"] + "\" title=\"" + dr["name"] + "\" class=\"medals\" />"; } else { dr["image"] = ""; } } else { dr["image"] = ""; } } cache.AddObject("/UI/MedalsList", dt); return(dt); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BaseConfigInfo bci = BaseConfigs.GetBaseConfig(); if (bci != null) { DatabaseInfo dbi = new DatabaseInfo(); dbi = Installer.GetDatabaseInfo(bci); ServerTextBox.Text = dbi.Server; DatabaseTextBox.Text = dbi.Database; UserTextBox.Text = dbi.User; PasswordTextBox.Text = dbi.Password; DBFileNameTextBox.Text = dbi.DBFile; if (DBFileNameTextBox.Text.IndexOf("\\") >= 0) { DBFileNameTextBox.Text = DBFileNameTextBox.Text.Substring(DBFileNameTextBox.Text.LastIndexOf("\\") + 1); } SelectDB = bci.DBType; CreateNewDBCheckBox.Checked = false; if (!CheckWebConfig()) { msg.Visible = true; } SiteConfigInfo sci = SiteConfigs.GetConfig(); if (sci != null) { WebsiteNameTextBox.Text = sci.SiteName; AdminNameTextBox.Text = sci.AdministratorName; } } } }
private bool AllowEditUser(int managerUId, int targetUId) { #region 是否可以编辑用户 int managerGroupId = Users.GetUserInfo(managerUId).Groupid; if (Users.GetUserInfo(managerUId).Adminid == 0) { return(false); } int targetGroupId = Users.GetUserInfo(targetUId).Groupid; int founderUId = BaseConfigs.GetBaseConfig().Founderuid; if (managerUId == targetUId) //可自身修改 { return(true); } else if (managerUId == founderUId) //创始人可修改 { return(true); } else if (managerGroupId == targetGroupId) //管理组相同的不能修改 { return(false); } else { return(true); } #endregion }
public virtual IHttpHandler GetHandler(HttpContext context, string requestType, string newUrl, string path) { string pagepath = path; BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); GeneralConfigInfo config = GeneralConfigs.GetConfig(); if (baseconfig != null && config != null) { string requestPath = context.Request.Path.ToLower(); foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls) { if (Regex.IsMatch(requestPath, url.Pattern, RegexOptions.IgnoreCase)) { if (url.Page != "") { string queryString = Regex.Replace(requestPath, url.Pattern, url.QueryString, RegexOptions.IgnoreCase); context.RewritePath(url.Page, string.Empty, queryString); pagepath = context.Server.MapPath(url.Page); break; } } } if (!newUrl.EndsWith(config.UrlExtName, true, null)) { newUrl += "default." + config.UrlExtName; } } return(PageParser.GetCompiledPageInstance(newUrl, pagepath, context)); }
/// <summary> /// 取得数据类型 /// </summary> /// <param name="dc"></param> /// <returns></returns> string GetDbType(We7DataColumn dc) { switch (dc.DataType) { case TypeCode.Char: return(String.Format("nchar ({0})", dc.MaxLength > 0 ? dc.MaxLength : 50)); case TypeCode.DateTime: return("datetime"); case TypeCode.Decimal: case TypeCode.Double: return("decimal"); case TypeCode.Int16: case TypeCode.Int32: case TypeCode.SByte: case TypeCode.UInt32: case TypeCode.UInt16: case TypeCode.Single: case TypeCode.Byte: case TypeCode.Boolean: return("int"); case TypeCode.UInt64: case TypeCode.Int64: return("bigint"); case TypeCode.String: string dbtype = BaseConfigs.GetBaseConfig().DBType; if (String.Compare(dbtype, "Access", true) == 0) { return(dc.MaxLength >= 255 ? "text" : String.Format("nvarchar ({0})", dc.MaxLength > 0 ? dc.MaxLength : 50)); } else if (String.Compare(dbtype, "SqlServer", true) == 0) { return(dc.MaxLength >= 4000 ? "text" : String.Format("nvarchar ({0})", dc.MaxLength > 0 ? dc.MaxLength : 50)); } else if (String.Compare(dbtype, "MySql", true) == 0) { return(dc.MaxLength >= 65535 ? "text" : String.Format("nvarchar ({0})", dc.MaxLength > 0 ? dc.MaxLength : 50)); } else if (String.Compare(dbtype, "Oracle", true) == 0) { return(dc.MaxLength >= 4000 ? "text" : String.Format("nvarchar ({0})", dc.MaxLength > 0 ? dc.MaxLength : 50)); } else if (String.Compare(dbtype, "SQLLite", true) == 0) { return(dc.MaxLength >= 4000 ? "text" : String.Format("nvarchar ({0})", dc.MaxLength > 0 ? dc.MaxLength : 50)); } else { return(dc.MaxLength >= 4000 ? "text" : String.Format("nvarchar ({0})", dc.MaxLength > 0 ? dc.MaxLength : 50)); } default: return(String.Format("nvarchar ({0})", 50)); } return("nvarchar (50)"); }
private bool CheckSponser(int uid) { #region 检查创建人 return(!((BaseConfigs.GetBaseConfig().Founderuid == uid) && (BaseConfigs.GetBaseConfig().Founderuid != this.userid))); #endregion }
protected void ResetDBInfo_Click(object sender, EventArgs e) { BaseConfigInfo bci = BaseConfigs.GetBaseConfig(); if (bci.DBConnectionString != "" && bci.DBType != "") { Installer.ExecuteSQLGroup(bci); Response.Redirect("succeed.aspx?from=install"); } }
private void ResetDBInfo_Click(object sender, EventArgs e) { //读取默认db.config文件内容 BaseConfigInfo bci = BaseConfigs.GetBaseConfig(); if (bci.DBType != "" && bci.DBConnectionString != "") { Installer.ExcuteSQLGroup(bci); this.Response.Redirect("succeed.aspx?from=install"); } }
/// <summary> /// 执行指定的数据文件 /// </summary> /// <param name="info"></param> /// <param name="dataDirectory"></param> /// <param name="filePath"></param> /// <param name="log"></param> /// <returns></returns> private void ExecuteDBFile(string dataDir, List <string> DBFileList) { foreach (string file in DBFileList) { string filePath = Path.Combine(dataDir, file); if (!File.Exists(filePath)) { throw new Exception(String.Format("数据文件{0}不存在!", file)); } ExcuteSQL(BaseConfigs.GetBaseConfig(), filePath); } }
public BaseConfigInfo GetBaseConfig() { try { return(BaseConfigs.GetBaseConfig()); } catch (Exception ex) { string source = "We7.CMS.Install-InstallWebService—GetBaseconfig"; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); throw ex; } }
private bool CheckSponser(int uid) { #region 检查创建人 if ((BaseConfigs.GetBaseConfig().Founderuid == uid) && (BaseConfigs.GetBaseConfig().Founderuid != this.userid)) { return(false); } else { return(true); } #endregion }
/// <summary> /// 当前用户是否是创始人 /// </summary> /// <param name="uid"></param> /// <returns></returns> public bool IsFounderUid(int uid) { if (BaseConfigs.GetBaseConfig().Founderuid == 0) return true; else { //如果当前登陆后台的用户就是论坛的创始人 if (BaseConfigs.GetBaseConfig().Founderuid == uid) { return true; } else { return false; } } }
/// <summary> /// 重写Url /// </summary> /// <param name="sender">事件的源</param> /// <param name="e">包含事件数据的 EventArgs</param> private void ReUrl_BeginRequest(object sender, EventArgs e) { BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); if (baseconfig == null) { return; } GeneralConfigInfo config = GeneralConfigs.GetConfig(); HttpContext context = ((HttpApplication)sender).Context; string requestPath = context.Request.Path.ToLower(); if (requestPath == "" || requestPath == "/" || requestPath == "/default.aspx") { return; } foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls) { if (Regex.IsMatch(requestPath, url.Pattern, RegexOptions.IgnoreCase)) { if (url.Page != "") { string newQueryString = Regex.Replace(requestPath, url.Pattern, url.QueryString, RegexOptions.IgnoreCase); string oldQuerystring = ""; if (context.Request.RawUrl.IndexOf("?") >= 0) { oldQuerystring = context.Request.RawUrl.Substring(context.Request.RawUrl.IndexOf("?") + 1); } if (oldQuerystring.Length > 0) { if (newQueryString.Length > 0) { newQueryString += "&" + oldQuerystring; } else { newQueryString = oldQuerystring; } } context.RewritePath(url.Page, string.Empty, newQueryString); } return; } } }
public static void ResetApplication() { lock (lockHelper) { HttpContext context = HttpContext.Current; context.Application.Clear(); if (context.Session != null) { context.Session.Clear(); } BaseConfigs.ResetConfig(); SiteConfigs.ResetConfig(); GeneralConfigs.ResetConfig(); context.Application["We7.Application.OnlinePeople.Key"] = 0; if (BaseConfigs.ConfigFileExist()) { BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); string root = context.Server.MapPath("~/"); string dataPath = context.Server.MapPath("~/App_Data/XML"); ObjectAssistant assistant = new ObjectAssistant(); try { if (baseconfig != null && baseconfig.DBConnectionString != "") { baseconfig.DBConnectionString = baseconfig.DBConnectionString.Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory).Replace("\\\\", "\\"); assistant.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver); } assistant.LoadDataSource(dataPath); } catch (DataException ex) { Debug.WriteLine(ex.ToString()); string s = string.Format("注意检查:/app_data/xml目录下的配置文件:\r\n错误代码:{0}\r\n错误消息:{1}", ex.Errorcode, ex.Message); LogHelper.WriteLog(typeof(ApplicationHelper), s); throw ex; } HelperFactory factory = new HelperFactory(); factory.Assistant = assistant; factory.Root = root; factory.Initialize(); context.Application["We7.HelperFactory"] = factory; } } }
[SoapHeader("header")] //用户身份验证的soap header public BaseConfigInfo GetBaseConfig() { //验证是否有权访问(当然,也可以通过查询数据库实现,具体视项目要求) if (!CheckAdmin(header.UserName, header.PassWord)) { throw new Exception("无权使用此服务"); } try { return(BaseConfigs.GetBaseConfig()); } catch (Exception ex) { string source = "We7.CMS.Install-InstallWebService—GetBaseconfig"; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); throw ex; } }
/// <summary> /// 将用户填写的数据库信息写入DNT.config文件 /// </summary> /// <param name="dataSource">数据库地址</param> /// <param name="userID">数据库账号</param> /// <param name="password">数据库账号密码</param> /// <param name="databaseName">数据库名</param> /// <param name="tablePrefix">表前缀</param> public static void EditDntConfig(string dataSource, string userID, string password, string databaseName, string tablePrefix) { BaseConfigInfo baseConfig = BaseConfigs.GetBaseConfig(); string connectionString = string.Format(@"Data Source={0};User ID={1};Password={2};Initial Catalog={3};Pooling=true", dataSource, userID, password, databaseName); baseConfig.Dbconnectstring = connectionString; baseConfig.Tableprefix = tablePrefix; baseConfig.Dbtype = "SqlServer"; string dntPath = Utils.GetMapPath("~/DNT.config"); if (!Utils.FileExists(dntPath)) { dntPath = Utils.GetMapPath("/DNT.config"); } SerializationHelper.Save(baseConfig, dntPath); DbHelper.ConnectionString = baseConfig.Dbconnectstring; BaseConfigs.ResetRealConfig(); }
private bool AllowDeleteUser(int managerUId, int byDeleterUId) { #region 判断将要删除的用户是否是创始人 int managerGroupId = Users.GetUserInfo(managerUId).Groupid; int byDeleterGruopid = Users.GetUserInfo(byDeleterUId).Groupid; int founderUId = BaseConfigs.GetBaseConfig().Founderuid; if (byDeleterUId == founderUId) //判断被删除人是否为创始人 { return(false); } else if (managerUId != founderUId && managerGroupId == byDeleterGruopid) //判断被删除人是否为相同组,即是否都是管理员,管理员不能相互删除 { return(false); } else { return(true); } #endregion }
private void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //读取默认db.config文件内容 BaseConfigInfo bci = BaseConfigs.GetBaseConfig(); if (bci != null) { //填充界面 DatabaseInfo dbi = new DatabaseInfo(); dbi = Installer.GetDatabaseInfo(bci); ServerTextBox.Text = dbi.Server; DatabaseTextBox.Text = dbi.Database; UserTextBox.Text = dbi.User; PasswordTextBox.Text = dbi.Password; DbFileNameTextBox.Text = dbi.DBFile; if (DbFileNameTextBox.Text.IndexOf("\\") > -1) { DbFileNameTextBox.Text = DbFileNameTextBox.Text.Substring(DbFileNameTextBox.Text.LastIndexOf("\\") + 1); } SelectDB = bci.DBType; CreateNewDBCheckBox.Checked = false; if (!CheckWebConfig()) { msg.Visible = true; } SiteConfigInfo si = SiteConfigs.GetConfig(); if (si != null) { WebsiteNameTextBox.Text = si.SiteName; AdminNameTextBox.Text = si.AdministratorName; } } AdminPasswordTextBox.Attributes.Add("onkeyup", "return loadinputcontext(this);"); } }
/// <summary> /// 重启应用程序 /// </summary> public static void LoadHelperFactory() { lock (lockHelper2) { //如果数据库配置文件存在,加载配置 if (BaseConfigs.ConfigFileExist()) { BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); //加载数据库映射表 string root = AppDomain.CurrentDomain.BaseDirectory; string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/XML"); ObjectAssistant assistat = new ObjectAssistant(); try { if (baseconfig != null && baseconfig.DBConnectionString != "") { baseconfig.DBConnectionString = baseconfig.DBConnectionString.Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory); assistat.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver); } assistat.LoadDataSource(dataPath); } catch (Thinkment.Data.DataException ex) { Debug.WriteLine(ex.ToString()); string source = "CD.Utils_CDHelper_ResetApplication"; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); throw ex; } HelperFactory hf = new HelperFactory(); hf.Assistant = assistat; hf.Root = root; hf.Initialize(); AppCtx.Cache.AddObject(HelperFactory.CacheKey, hf); } } }
/// <summary> /// 获得勋章列表 /// </summary> /// <returns>获得勋章列表</returns> public static DataTable GetMedalsList() { DNTCache cache = DNTCache.GetCacheService(); DataTable dt = cache.RetrieveObject("/Forum/UI/MedalsList") as DataTable; if (dt == null) { dt = DatabaseProvider.GetInstance().GetMedalsList(); string forumpath = BaseConfigs.GetBaseConfig().Forumpath; foreach (DataRow dr in dt.Rows) { if (dr["available"].ToString() == "1") { if (!Utils.StrIsNullOrEmpty(dr["image"].ToString())) { //当启用远程布署勋章图片时 if (EntLibConfigs.GetConfig() != null && !Utils.StrIsNullOrEmpty(EntLibConfigs.GetConfig().Medaldir)) { dr["image"] = "<img border=\"0\" src=\"" + EntLibConfigs.GetConfig().Medaldir + dr["image"] + "\" alt=\"" + dr["name"] + "\" title=\"" + dr["name"] + "\" />"; } else { dr["image"] = "<img border=\"0\" src=\"" + forumpath + "images/medals/" + dr["image"] + "\" alt=\"" + dr["name"] + "\" title=\"" + dr["name"] + "\" />"; } } else { dr["image"] = ""; } } else { dr["image"] = ""; } } cache.AddObject("/Forum/UI/MedalsList", dt); } return(dt); }
private void RunSql() { StringBuilder sb = new StringBuilder(); BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); string sqlpath = Utils.GetMapPath(upgradedir + "/sql.config"); if (!File.Exists(sqlpath)) { sqlpath = Utils.GetMapPath(BaseConfigs.GetForumPath.ToLower() + "upgrade/" + ver + "/sql.config"); } using (StreamReader objReader = new StreamReader(sqlpath, Encoding.UTF8)) { sb.Append(objReader.ReadToEnd()); objReader.Close(); } string[] sqlArray = sb.Replace("dnt_", baseconfig.Tableprefix).ToString().Trim().Split(new string[] { "GO\r\n", "go\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string sqlstr in sqlArray) { if (sqlstr.Trim() == "") { continue; } try { Databases.RunSql(sqlstr); } catch (Exception e) { Response.Write(e.Message); } } //foreach (string sqlstr in sb.Replace("dnt_", baseconfig.Tableprefix).ToString().Split(';')) //{ // DbHelper.ExecuteNonQuery(CommandType.Text, sqlstr); //} }
protected void Page_Load(object sender, EventArgs e) { We7MenuControl menu = new We7MenuControl(); //检查 if (menu.AllShowMemuItem.Count == 0) { lock (syncRoot) { if (menu.AllShowMemuItem.Count == 0) { // 无Menu数据则进行SQL执行 BaseConfigInfo bci = BaseConfigs.GetBaseConfig(); if (bci.DBType != "" && bci.DBConnectionString != "") { Installer.ExcuteSQLGroup(bci); ApplicationHelper.ResetApplication(); } } } } Response.Write(menu.AllMenuHtml()); Response.End(); }
private void ResetDBInfo_Click(object sender, EventArgs e) { CreateDataLogPath(); if (GenerateConfigCheckbox.Checked) { string configPath = Server.MapPath("~/config/db.config"); BaseConfigs.SaveConfigTo(DBConfig, configPath); BaseConfigs.ResetConfig(); } //读取默认db.config文件内容 BaseConfigInfo bci = BaseConfigs.GetBaseConfig(); if (bci != null && bci.DBType != "" && bci.DBConnectionString != "") { Installer.ExcuteSQLGroup(bci); this.Response.Redirect("succeed.aspx"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('无法读取数据库配置文件db.config,请检查重试。');</script>"); } }
private void CopyFilesButton_Click(object sender, EventArgs e) { //configuration文件夹改名 兼容2.7以前版本方法 string oldConfigPath = Path.Combine(Server.MapPath("~/"), "configuration"); if (Directory.Exists(oldConfigPath)) { string destDirName = Path.Combine(Server.MapPath("~/"), "config"); if (Directory.Exists(destDirName)) { Directory.Delete(destDirName, true); } Directory.Move(oldConfigPath, Path.Combine(Server.MapPath("~/"), "config")); } if (BackUpPanel.Visible) { if (BackUpCheckBox.Checked) { Installer.BackupOldFiles(Server.MapPath("~/"), Server.MapPath("~/_backup/update/")); } //检查是否有冗余文件 if (ClearOldCheckBox.Visible && ClearOldCheckBox.Checked) { //此处应该返回错误信息,目前存储在LOG文件中 DeleteFiles(); } } string ext = Path.GetExtension(UploadFile); switch (ext.ToLower()) { case ".zip": try { //DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath("~/bin")); //Helper.DeleteFileTree(directoryInfo, false); We7Helper.CopyDirectory(UnZipPath, Server.MapPath("~/")); Directory.Delete(UnZipPath, true); // /* * * 保存新版本号 * GeneralConfigInfo si = GeneralConfigs.GetConfig(); * if (si != null) * { * //si.ProductVersion = NewVersion; * GeneralConfigs.SaveConfig(si); * } */ RegisterScript("alert('操作成功!');location.href='upgrade-db.aspx?from=upgrade.aspx'"); } catch (IOException ex) { RegisterScript("alert('文件复制失败。原因:" + ex.Message + "');"); } break; case ".dll": try { string targetfile = Path.Combine(Server.MapPath("~/bin/"), Path.GetFileName(UploadFile)); File.Copy(UploadFile, targetfile, true); RegisterScript("alert('文件更新成功!');"); } catch (IOException ex) { RegisterScript("alert('文件复制失败。原因:" + ex.Message + "');"); } break; case ".xml": try { //读取默认db.config文件内容 BaseConfigInfo bci = BaseConfigs.GetBaseConfig(); if (bci != null && bci.DBType != "" && bci.DBConnectionString != "") { Installer.ExcuteSQL(bci, UploadFile); } RegisterScript("alert('XML文件执行成功!');"); } catch (IOException ex) { RegisterScript("alert(''XML文件执行出现错误。原因:" + ex.Message + "');"); } break; } }
/// <summary> /// 图片缓存方法 /// </summary> private void GetImage() { //检查参数是否合法 if (DNTRequest.GetString("aid") == "" || DNTRequest.GetString("size") == "" || DNTRequest.GetString("key") == "") { HttpContext.Current.Response.Redirect("images/common/none.gif"); return; } string forumPath = BaseConfigs.GetBaseConfig().Forumpath; //是否在服务器上缓存图片 bool nocache = DNTRequest.GetString("nocache") == "yes"; int aid = DNTRequest.GetInt("aid", 0); //缩略图缩略方式 string type = DNTRequest.GetString("type") != "" ? DNTRequest.GetString("type") : "fixwr"; string[] wxh = DNTRequest.GetString("size").Split('x'); //宽 int w = TypeConverter.StrToInt(wxh[0]); //高 int h = TypeConverter.StrToInt(wxh[1]); string thumbfile = string.Format("{0}_{1}_{2}.jpg'", aid, w, h); string attachurl = forumPath + "cache/thumbnail/"; //获取缓存图片 if (!nocache) { if (File.Exists(Utils.GetMapPath(attachurl + thumbfile))) { HttpContext.Current.Response.Redirect(attachurl + thumbfile); return; } } //校验参数正确性 string hash = Discuz.Common.DES.Encode(aid.ToString() + "," + w.ToString() + "," + h.ToString(), Utils.MD5(aid.ToString())).Replace("+", "["); if (hash != DNTRequest.GetString("key")) { HttpContext.Current.Response.Redirect("images/common/none.gif"); return; } AttachmentInfo attInfo = Attachments.GetAttachmentInfo(aid); //客户端缓存60分,在firefox下调试状态失效 HttpContext.Current.Response.Expires = 60; HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddMinutes(60); if (!Directory.Exists(Utils.GetMapPath(attachurl))) { Directory.CreateDirectory(Utils.GetMapPath(attachurl)); } //生成缩略图 if (attInfo.Filename.StartsWith("http://")) //远程附件 { Thumbnail.MakeRemoteThumbnailImage(attInfo.Filename, Utils.GetMapPath(attachurl + thumbfile), w, h); } else { Thumbnail.MakeThumbnailImage(Utils.GetMapPath(forumPath + "upload/" + attInfo.Filename), Utils.GetMapPath(attachurl + thumbfile), w, h); } if (nocache) { HttpContext.Current.Response.ContentType = "image/jpg"; HttpContext.Current.Response.BinaryWrite(File.ReadAllBytes(Utils.GetMapPath(attachurl + thumbfile))); try { File.Delete(Utils.GetMapPath(attachurl + thumbfile)); } catch { } } else { HttpContext.Current.Response.Redirect(attachurl + thumbfile); } }
/// <summary> /// 重启网站 /// </summary> public static void ResetApplication() { lock (lockHelper) { HttpContext context = HttpContext.Current; context.Application.Clear(); if (context.Session != null) { context.Session.Clear(); } BaseConfigs.ResetConfig(); SiteConfigs.ResetConfig(); GeneralConfigs.ResetConfig(); PluginManager.LoadPlugins(); context.Application["We7.Application.OnlinePeople.Key"] = 0; //如果数据库配置文件存在,加载配置 if (BaseConfigs.ConfigFileExist()) { BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); //加载数据库映射表 string root = context.Server.MapPath("~/"); string dataPath = context.Server.MapPath("~/App_Data/XML"); ObjectAssistant assistat = new ObjectAssistant(); try { if (baseconfig != null && baseconfig.DBConnectionString != "") { baseconfig.DBConnectionString = baseconfig.DBConnectionString. Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory).Replace("\\\\", "\\"); assistat.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver); } assistat.LoadDataSource(dataPath); } catch (Thinkment.Data.DataException ex) { Debug.WriteLine(ex.ToString()); string source = "CD.Utils_CDHelper_ResetApplication"; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); string msg = string.Format("注意检查:/app_data/xml里的配置文件:\r\n错误代码:{0}\r\n错误消息:{1}" , ex.ErrorCode, ex.Message); We7.Framework.LogHelper.WriteLog(typeof(ApplicationHelper), msg); throw ex; } HelperFactory hf = new HelperFactory(); /* * 添加内容模型表结构(系统内置字段已在LoadDataSource里添加) * author:丁乐 */ ModelHelper.ReCreateModelIndex(); MoudelMonitoring.SetModelDataDic(assistat); hf.Assistant = assistat; hf.Root = root; hf.Initialize(); context.Application.Add("We7.HelperFactory", hf); AppCtx.Cache.AddObject(HelperFactory.CacheKey, hf); MoudelMonitoring ml = new MoudelMonitoring(); //监控内容模型 } } }