/// <summary>
		/// Copies the elements of the specified <see cref="BaseConfigInfo">BaseConfigInfo</see> array to the end of the collection.
		/// </summary>
		/// <param name="value">An array of type <see cref="BaseConfigInfo">BaseConfigInfo</see> containing the Components to add to the collection.</param>
		public void AddRange(BaseConfigInfo[] value) 
		{
			for (int i = 0;	(i < value.Length); i = (i + 1)) 
			{
				this.Add(value[i]);
			}
		}
Esempio n. 2
0
		/// <summary>
        /// 静态构造函数初始化相应实例和定时器
		/// </summary>
        static BaseConfigs()
        {
            m_configinfo = BaseConfigFileManager.LoadConfig();
            baseConfigTimer.AutoReset = true;
            baseConfigTimer.Enabled = true;
            baseConfigTimer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed); 
            baseConfigTimer.Start();
        }
Esempio n. 3
0
        private bool EditDntConfig(BaseConfigInfo bci)
        {
            string filename = Utils.GetMapPath("~/DNT.config");

            if (!Utils.FileExists(filename))
            {
                filename = Utils.GetMapPath("/DNT.config");
            }

            try
            {
                SerializationHelper.Save(bci, filename);
                BaseConfigProvider.SetInstance(bci);
                return true;
            }
            catch
            {
                ErrProcess(bci);
            }
            return false;
        }
Esempio n. 4
0
        /*
		//重写web.config的DNT_ForumPath属性
		public void ResetForumPath(string webconfigpath)
		{
			XmlDocument  xmldoc= new XmlDocument();
			xmldoc.Load(webconfigpath);

			XmlNodeList topM=xmldoc.DocumentElement.ChildNodes;
			foreach(XmlNode element in topM)
			{
				if(element.Name.ToLower()=="appsettings")
				{
					XmlNodeList _node=element.ChildNodes;
					if ( _node.Count >0 ) 
					{
						foreach(XmlNode el in _node)
						{
							XmlNode pathnode=null;
							pathnode=el.SelectSingleNode("//add[@key ='DNT_ForumPath']");
							pathnode.Attributes["value"].Value=forumpath.Text;
						}
					}
				}
			}
			xmldoc.Save(webconfigpath);
		}
		*/
        #endregion

        protected void ClearDBInfo_Click(object sender, EventArgs e)
        {

            #region 验证输入
            //验证密码长度
            if (systemadminpws.Text.Length < 6)
            {
#if NET1
                Page.RegisterStartupScript("", "<script>alert('系统管理员密码长度不能少于6位');</script>");
#else
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统管理员密码长度不能少于6位');</script>");
#endif
                return;
            }
            //验证数据库名为空
            if (initialcatalog.Text.Length == 0 && ddlDbType.SelectedValue != "Access")
            {
#if NET1
                Page.RegisterStartupScript("", "<script>alert('数据库名不能为空');</script>");
#else
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('数据库名不能为空');</script>");
#endif
                return;
            }

            //验证数据库表前缀不能为数字开头
            if (!Regex.IsMatch(tableprefix.Text, "^[a-zA-Z_](.*)", RegexOptions.IgnoreCase))
            {
#if NET1
                Page.RegisterStartupScript("", "<script>alert('数据库表前缀必须以字母开头');</script>");
#else
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('数据库表前缀必须以字母开头');</script>");
#endif
                return;
            }
            //验证必须选择数据库类型
            if (ddlDbType.SelectedIndex == 0)
            {
#if NET1
                Page.RegisterStartupScript("", "<script>alert('请选择数据库类型');</script>");
#else
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择数据库类型');</script>");
#endif
                return;
            }

            if (webtitle.Text.Trim() == string.Empty && forumtitle.Text.Trim() != string.Empty)
            {
                webtitle.Text = forumtitle.Text;
            }

            #endregion

            #region 写general.config文件
            try
            {
                DNTCache cache = DNTCache.GetCacheService();
                cache.RemoveObject("/Forum/PostTableName");
                cache.RemoveObject("/Forum/LastPostTableName");


                //记录加密串到general.config
                GeneralConfigInfo __configinfo = GeneralConfigs.Deserialize(Server.MapPath("../config/general.config"));
                __configinfo.Passwordkey = ForumUtils.CreateAuthStr(10);
                __configinfo.Forumtitle = forumtitle.Text;
                __configinfo.Forumurl = forumurl.Text;
                __configinfo.Webtitle = webtitle.Text;
                __configinfo.Weburl = weburl.Text;
                GeneralConfigs.Serialiaze(__configinfo, Server.MapPath("../config/general.config"));
                __configinfo = null;

            }
            catch { ;}
            #endregion

            string connectionString = string.Empty;
            //判断数据库类型,填充数据库字符串
            selectDbType = ddlDbType.SelectedValue;
            //access文件路径
            string path = Utils.GetMapPath(forumpath.Text + "database/" + txtDbFileName.Text);
            switch (selectDbType)
            {
                case "SqlServer":
                    connectionString =
                        string.Format(@"Data Source={0};User ID={1};Password={2};Initial Catalog={3};Pooling=true",
                                      datasource.Text, userid.Text, password.Text, initialcatalog.Text);
                    break;

                case "MySql":
                    connectionString =
                        string.Format(@"Data Source={0};Port=3306;User ID={1};Password={2};Initial Catalog={3};Pooling=true;Allow Zero Datetime=true", datasource.Text, userid.Text, password.Text, initialcatalog.Text);
                    break;

                case "Access":
                    connectionString =
                        string.Format(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source={0};Persist Security Info=True;", path);
                    break;
            }

            BaseConfigInfo baseConfig = new BaseConfigInfo();
            baseConfig.Dbconnectstring = connectionString;
            baseConfig.Dbtype = selectDbType;
            baseConfig.Forumpath = forumpath.Text;
            baseConfig.Founderuid = sponsercheck.Checked ? 1 : 0;
            baseConfig.Tableprefix = tableprefix.Text;

            Session["SystemAdminName"] = systemadminname.Text;
            Session["SystemAdminPws"] = systemadminpws.Text;
            Session["dbname"] = initialcatalog.Text;
            Session["Dbconnectstring"] = connectionString;
            Session["Tableprefix"] = tableprefix.Text;
            Session["SystemAdminEmail"] = adminemail.Text.TrimEnd();
            //验证链接

            if (!EditDntConfig(baseConfig))
            {
                ClearDBInfo.Enabled = false;
#if NET1
                Page.RegisterStartupScript( "", "<script>if(confirm('无法把设置写入\"DNT.config\"文件, 系统将把文件内容显示出来, 您可以将内容保存为\"DNT.config\", 然后通过FTP软件上传到网站根目录下.. \\r\\n*注意: DNT.config位于网站根目录, 而非论坛根目录\\r\\n\\r\\n如果要继续运行安装, 请点击\"确定\"按钮. ')) {window.location.href='step4.aspx?isforceload=1';}</script>");
#else
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>if(confirm('无法把设置写入\"DNT.config\"文件, 系统将把文件内容显示出来, 您可以将内容保存为\"DNT.config\", 然后通过FTP软件上传到网站根目录下.. \\r\\n*注意: DNT.config位于网站根目录, 而非论坛根目录\\r\\n\\r\\n如果要继续运行安装, 请点击\"确定\"按钮. ')) {window.location.href='step4.aspx?isforceload=1';}else{window.location.href='step3.aspx';}</script>");
#endif
                return;
            }

            string setupDbType = ddlDbType.SelectedValue;
            DbHelper.ResetDbProvider();

            if (!CheckConnection())
            {
#if NET1
                Page.RegisterStartupScript("", "<script>alert('连接数据库失败,请检查您填写的数据库信息。');</script>");
#else
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('连接数据库失败,请检查您填写的数据库信息。');</script>");
#endif
                return;
            }
            else
            {
                Response.Redirect(Utils.HtmlEncode(String.Format("step4.aspx?db={0}", setupDbType)));
            }
        }
		/// <summary>
		/// Copies the collection Components to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index.
		/// </summary>
		/// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param>
		/// <param name="index">The index of the array at which to begin inserting.</param>
		public void CopyTo(BaseConfigInfo[] array, int index) 
		{
			this.List.CopyTo(array, index);
		}
Esempio n. 6
0
 public void Insert(int index, BaseConfigInfo value)
 {
     List.Insert(index, value);
 }
 /// <summary>
 /// 初始化文件修改时间和对象实例
 /// </summary>
 static BaseConfigFileManager()
 {
     m_fileoldchange = System.IO.File.GetLastWriteTime(ConfigFilePath);
     m_configinfo    = (BaseConfigInfo)DefaultConfigFileManager.DeserializeInfo(ConfigFilePath, typeof(BaseConfigInfo));
 }
Esempio n. 8
0
        /// <summary>
        /// 重写Url
        /// </summary>
        /// <param name="sender">事件的源</param>
        /// <param name="e">包含事件数据的 EventArgs</param>
        private void ReUrl_BeginRequest(object sender, EventArgs e)
        {
            BaseConfigInfo baseconfig = new BaseConfigInfo();
            if (baseconfig == null)
            {
                return;
            }
            GeneralConfigInfo config = GeneralConfigs.GetConfig();
            HttpContext context = ((HttpApplication)sender).Context;
            string forumPath = (context.Request.ApplicationPath).ToLower();

            //if (context.Request.Url.AbsoluteUri.IndexOf("localhost") > 0 || context.Request.Url.AbsoluteUri.IndexOf("127.0.0.1") > 0)
            //{
            //    forumPath = forumPath + "/";
            //}

            forumPath = forumPath + "/";

            string requestPath = context.Request.Path.ToLower();

            if (requestPath.StartsWith(forumPath) && !requestPath.EndsWith(".axd"))
            {
                if (requestPath.Substring(forumPath.Length).IndexOf("/") == -1)
                {                    // 当前样式id   
                    string strTemplateid = config.Templateid.ToString();
                    if (Utils.InArray(Utils.GetCookie(Utils.GetTemplateCookieName()), Templates.GetValidTemplateIDList()))
                    {
                        strTemplateid = Utils.GetCookie(Utils.GetTemplateCookieName());
                    }

                    if (requestPath.EndsWith("/index.aspx"))
                    {
                        if (config.Indexpage == 0)
                        {
                            if (config.BrowseCreateTemplate == 1)
                            {
                                CreateTemplate(forumPath, Templates.GetTemplateItem(int.Parse(strTemplateid)).Directory, "forumindex.aspx", int.Parse(strTemplateid));
                            }
                            context.RewritePath(forumPath + "aspx/" + strTemplateid + "/forumindex.aspx");
                        }
                        else
                        {
                            if (config.BrowseCreateTemplate == 1)
                            {
                                CreateTemplate(forumPath, Templates.GetTemplateItem(int.Parse(strTemplateid)).Directory, "website.aspx", int.Parse(strTemplateid));
                            }
                            context.RewritePath(forumPath + "aspx/" + strTemplateid + "/website.aspx");
                        }

                        return;
                    }


                    //当使用伪aspx, 如:showforum-1.aspx等.
                    if (config.Aspxrewrite == 1)
                    {
                        foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls)
                        {
                            if (Regex.IsMatch(requestPath, url.Pattern, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase))
                            {
                                string newUrl = Regex.Replace(requestPath.Substring(context.Request.Path.LastIndexOf("/")), url.Pattern, url.QueryString, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase);
                                if (config.BrowseCreateTemplate == 1)
                                {
                                    CreateTemplate(forumPath, Templates.GetTemplateItem(int.Parse(strTemplateid)).Directory, url.Page.Replace("/", ""), int.Parse(strTemplateid));
                                }
                                //通过参数设置指定模板
                                if (config.Specifytemplate > 0)
                                {
                                    strTemplateid = SelectTemplate(strTemplateid, url.Page, newUrl);
                                }
                                context.RewritePath(forumPath + "aspx/" + strTemplateid + url.Page, string.Empty, newUrl + "&selectedtemplateid=" + strTemplateid);

                                return;
                            }
                        }
                    }

                    if (config.BrowseCreateTemplate == 1)
                    {
                        if (requestPath.IndexOf("showtemplate.aspx") != -1)
                        {
                            CreateTemplate(forumPath,
                                Templates.GetTemplateItem(DNTRequest.GetInt("templateid", 1)).Directory,
                                config.Indexpage == 0 ? "forumindex.aspx" : "website.aspx",
                                DNTRequest.GetInt("templateid", 1)); //当跳转模板页时,生成目标文件
                        }
                        CreateTemplate(forumPath, Templates.GetTemplateItem(int.Parse(strTemplateid)).Directory, requestPath.Substring(context.Request.Path.LastIndexOf("/")).Replace("/", ""), int.Parse(strTemplateid));

                    }
                    //通过参数设置指定模板
                    if (config.Specifytemplate > 0)
                    {
                        strTemplateid = SelectTemplate(strTemplateid, requestPath, context.Request.QueryString.ToString());
                    }
                    context.RewritePath(forumPath + "aspx/" + strTemplateid + requestPath.Substring(context.Request.Path.LastIndexOf("/")), string.Empty, context.Request.QueryString.ToString() + "&selectedtemplateid=" + strTemplateid);
                }
                else if (requestPath.StartsWith(forumPath + "archiver/"))
                {
                    //当使用伪aspx, 如:showforum-1.aspx等.
                    if (config.Aspxrewrite == 1)
                    {
                        string path = requestPath.Substring(forumPath.Length + 8);
                        foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls)
                        {
                            if (Regex.IsMatch(path, url.Pattern, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase))
                            {
                                string newUrl = Regex.Replace(path, url.Pattern, url.QueryString, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase);

                                context.RewritePath(forumPath + "archiver" + url.Page, string.Empty, newUrl);
                                return;
                            }
                        }

                    }
                    return;
                }
                else if (requestPath.StartsWith(forumPath + "tools/"))
                {
                    //当使用伪aspx, 如:showforum-1.aspx等.
                    if (config.Aspxrewrite == 1)
                    {
                        string path = requestPath.Substring(forumPath.Length + 5);
                        foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls)
                        {
                            if (Regex.IsMatch(path, url.Pattern, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase))
                            {
                                string newUrl = Regex.Replace(path, url.Pattern, Utils.UrlDecode(url.QueryString), Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase);

                                context.RewritePath(forumPath + "tools" + url.Page, string.Empty, newUrl);
                                return;
                            }
                        }
                    }
                    return;
                }
                else if (requestPath.StartsWith(forumPath + "upload/") || requestPath.StartsWith(forumPath + "space/upload/"))
                {
                    context.RewritePath(forumPath + "index.aspx");
                    return;
                }
            }
        }
		public void Remove(BaseConfigInfo value) 
		{
			List.Remove(value);
		}
		public void Insert(int index, BaseConfigInfo value)	
		{
			List.Insert(index, value);
		}
		/// <summary>
		/// Gets the index in the collection of the specified <see cref="BaseConfigInfoCollection">BaseConfigInfoCollection</see>, if it exists in the collection.
		/// </summary>
		/// <param name="value">The <see cref="BaseConfigInfoCollection">BaseConfigInfoCollection</see> to locate in the collection.</param>
		/// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
		public int IndexOf(BaseConfigInfo value) 
		{
			return this.List.IndexOf(value);
		}
Esempio n. 12
0
 /// <summary>
 /// Gets a value indicating whether the collection contains the specified <see cref="BaseConfigInfoCollection">BaseConfigInfoCollection</see>.
 /// </summary>
 /// <param name="value">The <see cref="BaseConfigInfoCollection">BaseConfigInfoCollection</see> to search for in the collection.</param>
 /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
 public bool Contains(BaseConfigInfo value)
 {
     return(this.List.Contains(value));
 }
Esempio n. 13
0
 public int Add(BaseConfigInfo value)
 {
     return(this.List.Add(value));
 }
Esempio n. 14
0
 public void Remove(BaseConfigInfo value)
 {
     List.Remove(value);
 }
Esempio n. 15
0
        private void ErrProcess(BaseConfigInfo config)
        {
            string Mydntconfig = "<?xml version=\"1.0\"?>\r\n";

            Mydntconfig += "<BaseConfigInfo xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n";
            Mydntconfig += "<Dbconnectstring>" + config.Dbconnectstring + "</Dbconnectstring>\r\n";
            Mydntconfig += "<Tableprefix>" + config.Tableprefix + "</Tableprefix>\r\n";
            Mydntconfig += "<Forumpath>" + config.Forumpath + "</Forumpath>\r\n";
            Mydntconfig += "<Dbtype>" + config.Dbtype + "</Dbtype>\r\n";
            Mydntconfig += "<Founderuid>0</Founderuid>\r\n";
            Mydntconfig += "</BaseConfigInfo>\r\n";

            Session["My_DNT.congif"] = Mydntconfig;
            Session["Dbconnectstring"] = config.Dbconnectstring;
            Session["Tableprefix"] = config.Tableprefix;
        }
Esempio n. 16
0
 /// <summary>
 /// 重设配置类实例
 /// </summary>
 public static void ResetRealConfig()
 {
     m_configinfo = BaseConfigFileManager.LoadRealConfig();
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="BaseConfigInfoCollection">BaseConfigInfoCollection</see> class containing the specified array of <see cref="BaseConfigInfo">BaseConfigInfo</see> Components.
		/// </summary>
		/// <param name="value">An array of <see cref="BaseConfigInfo">BaseConfigInfo</see> Components with which to initialize the collection. </param>
		public BaseConfigInfoCollection(BaseConfigInfo[] value)
		{
			this.AddRange(value);
		}
Esempio n. 18
0
 /// <summary>
 /// 保存配置实例
 /// </summary>
 /// <param name="baseconfiginfo"></param>
 /// <returns></returns>
 public static bool SaveConfig(BaseConfigInfo baseconfiginfo)
 {
     BaseConfigFileManager acfm = new BaseConfigFileManager();
     BaseConfigFileManager.ConfigInfo = baseconfiginfo;
     return acfm.SaveConfig();
 }
		public int Add(BaseConfigInfo value) 
		{
			return this.List.Add(value);
		}
Esempio n. 20
0
 /// <summary>
 /// 重设配置类实例
 /// </summary>
 public static void ResetRealConfig()
 {
     m_configinfo = BaseConfigFileManager.LoadRealConfig();
 }
		/// <summary>
		/// Gets a value indicating whether the collection contains the specified <see cref="BaseConfigInfoCollection">BaseConfigInfoCollection</see>.
		/// </summary>
		/// <param name="value">The <see cref="BaseConfigInfoCollection">BaseConfigInfoCollection</see> to search for in the collection.</param>
		/// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
		public bool Contains(BaseConfigInfo value) 
		{
			return this.List.Contains(value);
		}
Esempio n. 22
0
 /// <summary>
 /// 初始化文件修改时间和对象实例
 /// </summary>
 static BaseConfigFileManager()
 {
     m_fileoldchange = System.IO.File.GetLastWriteTime(ConfigFilePath);
     m_configinfo = (BaseConfigInfo) DefaultConfigFileManager.DeserializeInfo(ConfigFilePath, typeof(BaseConfigInfo));
 }
Esempio n. 23
0
 /// <summary>
 /// Gets the index in the collection of the specified <see cref="BaseConfigInfoCollection">BaseConfigInfoCollection</see>, if it exists in the collection.
 /// </summary>
 /// <param name="value">The <see cref="BaseConfigInfoCollection">BaseConfigInfoCollection</see> to locate in the collection.</param>
 /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
 public int IndexOf(BaseConfigInfo value)
 {
     return(this.List.IndexOf(value));
 }