Exemple #1
0
        protected void ResetDBInfo_Click(object sender, EventArgs e)
        {
            #region 验证输入
            //验证密码长度
            if (AdminPasswordTextBox.Text.Length < 6)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统管理员密码长度不能少于6位');</script>");
                return;
            }
            //验证数据库名为空
            if (DatabaseTextBox.Text.Length == 0 && DbTypeDropDownList.SelectedValue == "SqlServer")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('数据库名不能为空');</script>");
                return;
            }

            //验证必须选择数据库类型
            if (DbTypeDropDownList.SelectedIndex == 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择数据库类型');</script>");
                return;
            }

            #endregion

            #region 写Site.config文件
            try
            {
                SiteConfigInfo __configinfo;
                //记录存储到SiteConfig.config
                try
                {
                    __configinfo = SiteConfigs.GetConfig();
                }
                catch
                {
                    __configinfo = new SiteConfigInfo();
                }
                __configinfo.AdministratorKey  = Encrypt(AdminPasswordTextBox.Text);
                __configinfo.IsPasswordHashed  = true;
                __configinfo.SiteName          = WebsiteNameTextBox.Text;
                __configinfo.AdministratorName = AdminNameTextBox.Text;
                SiteConfigs.Serialiaze(__configinfo, Server.MapPath("~/config/site.config"));
                Session["SystemAdminName"] = AdminNameTextBox.Text;
                Session["SystemAdminPws"]  = AdminPasswordTextBox.Text;
            }
            catch {; }
            #endregion

            string setupDbType = SelectDB = DbTypeDropDownList.SelectedValue;

            DatabaseInfo dbi = new DatabaseInfo();
            dbi.Server   = ServerTextBox.Text;
            dbi.Database = DatabaseTextBox.Text;
            dbi.User     = UserTextBox.Text;
            dbi.Password = PasswordTextBox.Text;
            dbi.DBFile   = DbFileNameTextBox.Text;

            BaseConfigInfo baseConfig = Installer.GenerateConnectionString(setupDbType, dbi);

            //验证链接

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

            //下面数据库需要手工创建
            if (baseConfig.DBType == "Oracle" || baseConfig.DBType == "MySql")
            {
                CreateNewDBCheckBox.Checked = false;
            }

            if (CreateNewDBCheckBox.Checked)//创建数据库
            {
                Exception ex  = null;
                int       ret = Installer.CreateDatabase(baseConfig, out ex);
                if (ret == -1)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('数据库已存在,请重新命名或去掉重新“创建新数据库”前面的勾,使用已有数据库。');</script>");
                    return;
                }
                else if (ret == 0)
                {
                    string exceptionMsgs = We7Helper.ConvertTextToHtml(ex.Message);
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('创建数据库发生错误。错误原因:" + exceptionMsgs + "');</script>");
                    return;
                }
            }

            string msg = "";
            if (!Installer.CheckConnection(baseConfig, out msg))
            {
                msg = We7Helper.ConvertTextToHtml(msg);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('连接数据库失败,请检查您填写的数据库信息。" + msg + "');</script>");
                return;
            }
            else
            {
                Response.Redirect(Server.HtmlEncode(String.Format("step4.aspx?db={0}", setupDbType)));
            }
        }
Exemple #2
0
        protected override void Initialize()
        {
            SiteConfigInfo    ci = SiteConfigs.GetConfig();
            GeneralConfigInfo si = GeneralConfigs.GetConfig();

            SiteNameTextBox.Text             = si.SiteTitle;
            txtSiteFullName.Text             = si.SiteFullName;
            ImageValue.Text                  = si.SiteLogo;
            txtIcpInfo.Text                  = si.IcpInfo;
            RootUrlTextBox.Text              = ci.RootUrl;
            IsHashedPasswordCheckBox.Checked = ci.IsPasswordHashed;
            txtSN.Text = ci.PluginSN;

            AllowSignupCheckBox.Checked = si.AllowSignup == "True";
            //DefaultTemplateGroupTextBox.Text = si.DefaultTemplateGroup;
            DefaultTemplateGroupFileNameTextBox.Text = si.DefaultTemplateGroupFileName;

            HomePageTitleTextBox.Text    = si.DefaultHomePageTitle;
            ChannelPageTitleTextBox.Text = si.DefaultChannelPageTitle;
            ContentPageTitleTextBox.Text = si.DefaultContentPageTitle;


            SySMailUserTextBox.Text       = si.SysMailUser;
            SysMailPassTextBox.Text       = si.SysMailPassword;
            SysMailServerTextBox.Text     = si.SysMailServer;
            SystemMailTextBox.Text        = si.SystemMail;
            NotifyMailTextBox.Text        = si.NotifyMail;
            GenericUserManageTextBox.Text = si.GenericUserManageType;
            SysPopServerTextBox.Text      = si.SysPopServer;

            //IsHashedPasswordCheckBox.Checked = si.IsPasswordHashed;
            IsAddLogCheckBox.Checked       = si.IsAddLog;
            IsAuditCommentCheckBox.Checked = si.IsAuditComment;

            EnableLoginAuhenCodeCheckBox.Checked = (si.EnableLoginAuhenCode == "true");

            AshxRadioButton.Checked   = (si.UrlFormat == "aspx");
            HtmlRadioButton.Checked   = (si.UrlFormat == "html");
            IISRadioButton.Checked    = (si.UrlRewriterProvider == "iis");
            ASPNETRadioButton.Checked = (si.UrlRewriterProvider == "asp.net");

            ArticleUrlGeneratorTextBox.Text = si.ArticleUrlGenerator;
            ArticleUrlGeneratorDropDownList.SelectedValue = si.ArticleUrlGenerator;
            if (ArticleUrlGeneratorDropDownList.SelectedIndex == -1)
            {
                ArticleUrlGeneratorDropDownList.SelectedIndex = 3;
            }

            ArticleSourceDefaultTextBox.Text = si.ArticleSourceDefault;

            ArticleAutoPublish.Checked = (si.ArticleAutoPublish == "true");
            ArticleAutoShare.Checked   = (si.ArticleAutoShare == "true");

            KeywordPageMetaTextBox.Text     = si.KeywordPageMeta;
            DescriptionPageMetaTextBox.Text = si.DescriptionPageMeta;


            ADUrlTextBox.Text = ci.ADUrl;

            EnableCache.Checked                   = (si.EnableCache == "true");
            CacheTimeSpanTextBox.Text             = si.CacheTimeSpan.ToString();
            OnlyLoginUserCanVisitCheckBox.Checked = si.OnlyLoginUserCanVisit;
            StartTemplateMapCheckbox.Checked      = si.StartTemplateMap;
            SiteStateDropDownList.SelectedValue   = si.SiteBuildState.ToLower();
            AllowParentArticleCheckBox.Checked    = si.AllowParentArticle;
            EnableSingleTable.Checked             = si.EnableSingleTable;
            UseVisualTemplateCheckBox.Checked     = si.DefaultTemplateEditor == "1";
            EnableHtmlTemplate.Checked            = si.EnableHtmlTemplate;

            hddnIPStrategy.Value         = si.IPStrategy;
            ipstrategy.Attributes["src"] = "SystemStrategy.aspx?ipstrategy=" + si.IPStrategy;
            txtSSOUrls.Text   = si.SSOSiteUrls;
            txtLinks.Text     = si.Links;
            txtCopyright.Text = si.Copyright;

            //注册验证模式
            List <ListItem> listItems = new List <ListItem>();

            listItems.Add(new ListItem("不审核", "none"));
            listItems.Add(new ListItem("邮箱验证", "email"));
            listItems.Add(new ListItem("人工审核", "manual"));

            drpUserRegiseterMode.DataSource    = listItems;
            drpUserRegiseterMode.SelectedValue = si.UserRegisterMode;
            drpUserRegiseterMode.DataBind();
        }
Exemple #3
0
        string BuildNavString()
        {
            string strActive = @"<LI class=TabIn id=tab{0} style='display:{2}'><A>{1}</A> </LI>";
            string strLink   = @"<LI class=TabOut id=tab{0}  style='display:{2}'><A  href={3}>{1}</A> </LI>";
            int    tab       = 1;
            string tabString = "";
            string dispay    = "";
            string rawurl    = We7Helper.RemoveParamFromUrl(Request.RawUrl, "tab");

            rawurl = We7Helper.RemoveParamFromUrl(Request.RawUrl, "saved");

            //记录操作历史,按照操作历史延续
            if (!We7Helper.IsEmptyID(ChannelID) && Session["$We7_Channel_Tab"] != null)
            {
                tab = (int)Session["$We7_Channel_Tab"];
            }

            if (TabID != null && We7Helper.IsNumber(TabID) && int.Parse(TabID) > 0)
            {
                tab = int.Parse(TabID);
            }

            if (tab == 1)
            {
                tabString += string.Format(strActive, 1, "基本信息", dispay);
                Control ctl = this.LoadControl("controls/Channel_basic.ascx");
                ContentHolder.Controls.Add(ctl);
            }
            else
            {
                tabString += string.Format(strLink, 1, "基本信息", dispay, We7Helper.AddParamToUrl(rawurl, "tab", "1"));
            }

            if (!We7Helper.IsEmptyID(ChannelID))
            {
                if (tab == 2)
                {
                    tabString += string.Format(strActive, 2, "选项", dispay);
                    Control ctl = this.LoadControl("controls/Channel_option.ascx");
                    ContentHolder.Controls.Add(ctl);
                }
                else
                {
                    tabString += string.Format(strLink, 2, "选项", dispay, We7Helper.AddParamToUrl(rawurl, "tab", "2"));
                }


                if (tab == 3)
                {
                    tabString += string.Format(strActive, 3, "模板", dispay);
                    Control ctl = this.LoadControl("controls/Channel_template.ascx");
                    ContentHolder.Controls.Add(ctl);
                }
                else
                {
                    tabString += string.Format(strLink, 3, "模板", dispay, We7Helper.AddParamToUrl(rawurl, "tab", "3"));
                }


                if (tab == 4)
                {
                    tabString += string.Format(strActive, 4, "标签", dispay);
                    Control ctl = this.LoadControl("controls/Channel_tag.ascx");
                    ContentHolder.Controls.Add(ctl);
                }
                else
                {
                    tabString += string.Format(strLink, 4, "标签", dispay, We7Helper.AddParamToUrl(rawurl, "tab", "4"));
                }


                if (tab == 5)
                {
                    tabString += string.Format(strActive, 5, "权限", dispay);
                    Control ctl = this.LoadControl("controls/Channel_authorize.ascx");
                    ContentHolder.Controls.Add(ctl);
                }
                else
                {
                    tabString += string.Format(strLink, 5, "权限", dispay, We7Helper.AddParamToUrl(rawurl, "tab", "5"));
                }

                if (SiteConfigs.GetConfig().SiteGroupEnabled)
                {
                    MoreEventArgs evenArgs = new MoreEventArgs();
                    //ShareEvent shareEvent =  new ShareEvent();
                    //shareEvent
                    ShareEventFactory.Instance.OnLoadChannelShareConfig(tab, evenArgs);
                    tabString += evenArgs.ReturnValue;
                    Control c = evenArgs.ReturnObject as Control;
                    if (c != null)
                    {
                        ContentHolder.Controls.Add(c);
                    }
                }
                if (System.IO.File.Exists(Server.MapPath("/Plugins/IPStrategyPlugin/Plugin.xml")))
                {
                    if (tab == 7)
                    {
                        tabString += string.Format(strActive, 7, "IP过滤", dispay);
                        Control ctl = this.LoadControl("controls/StrategySet.ascx");
                        if (ctl is StrategySet)
                        {
                            ((StrategySet)ctl).Mode = StrategyMode.CHANNEL;
                        }
                        ContentHolder.Controls.Add(ctl);
                    }
                    else
                    {
                        tabString += string.Format(strLink, 7, "IP过滤", dispay, We7Helper.AddParamToUrl(rawurl, "tab", "7"));
                    }
                }


                //if (tab == 8)
                //{
                //    tabString += string.Format(strActive, 8, "附加模块", dispay);
                //    Control ctl = this.LoadControl("controls/Channel_Module.ascx");
                //    ContentHolder.Controls.Add(ctl);
                //}
                //else
                //    tabString += string.Format(strLink, 8, "附加模块", dispay, We7Helper.AddParamToUrl(rawurl, "tab", "8"));
            }

            Session["$We7_Channel_Tab"] = tab;
            return(tabString);
        }
Exemple #4
0
        public List <Department> GetDepartmentList()
        {
            string            siteID      = SiteConfigs.GetConfig().SiteGroupEnabled ? SiteConfigs.GetConfig().SiteID : string.Empty;
            List <Department> departments = new List <Department>();

            departments = AccountHelper.GetDepartments(siteID, string.Empty, string.Empty, new string[] { "ParentID", "ID", "Name", "FullName" });
            //List<Department> departmentList = new List<Department>();
            //if (departments != null)
            //{
            //    foreach (Department depList in departments)
            //    {
            //        if (depList.FullName != "")
            //        {
            //            int c = depList.FullName.Length - depList.FullName.Replace("/", String.Empty).Length;
            //            for (int i = 0; i < c; i++)
            //            {
            //                depList.Name = "&nbsp;" + "&nbsp;" + "&nbsp;" + depList.Name;
            //            }
            //        }
            //        departmentList.Add(depList);
            //    }
            //}
            //return departmentList;
            return(departments);
        }
Exemple #5
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            if (AppCtx.IsDemoSite)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "aler", "alert('演示站点,不能修改选项!');", true);
                return;
            }

            SiteConfigInfo    ci = SiteConfigs.GetConfig();
            GeneralConfigInfo si = GeneralConfigs.GetConfig();

            ci.SiteName         = SiteNameTextBox.Text;
            si.SiteTitle        = SiteNameTextBox.Text;
            ci.RootUrl          = RootUrlTextBox.Text;
            ci.IsPasswordHashed = IsHashedPasswordCheckBox.Checked;
            ci.ADUrl            = ADUrlTextBox.Text.Trim();
            ci.PluginSN         = txtSN.Text.Trim();
            si.SiteFullName     = txtSiteFullName.Text;
            si.SiteLogo         = ImageValue.Text;
            si.IcpInfo          = txtIcpInfo.Text;

            si.AllowSignup = AllowSignupCheckBox.Checked ? "True" : "False";
            //si.DefaultTemplateGroup = DefaultTemplateGroupTextBox.Text;
            si.DefaultTemplateGroupFileName = DefaultTemplateGroupFileNameTextBox.Text;
            si.DefaultHomePageTitle         = HomePageTitleTextBox.Text;
            si.DefaultChannelPageTitle      = ChannelPageTitleTextBox.Text;
            si.DefaultContentPageTitle      = ContentPageTitleTextBox.Text;

            si.DescriptionPageMeta = DescriptionPageMetaTextBox.Text;
            si.KeywordPageMeta     = KeywordPageMetaTextBox.Text;

            si.NotifyMail = NotifyMailTextBox.Text;

            si.SysMailUser           = SySMailUserTextBox.Text;
            si.SysMailPassword       = SysMailPassTextBox.Text;
            si.SysMailServer         = SysMailServerTextBox.Text;
            si.SystemMail            = SystemMailTextBox.Text;
            si.GenericUserManageType = GenericUserManageTextBox.Text;
            si.SysPopServer          = SysPopServerTextBox.Text;

            si.IsAddLog       = IsAddLogCheckBox.Checked;
            si.IsAuditComment = IsAuditCommentCheckBox.Checked;

            si.UrlFormat           = (AshxRadioButton.Checked) ? "aspx" : "html";
            si.UrlRewriterProvider = (IISRadioButton.Checked) ? "iis" : "asp.net";
            if (ArticleUrlGeneratorDropDownList.SelectedIndex == 3)
            {
                si.ArticleUrlGenerator = ArticleUrlGeneratorTextBox.Text;
            }
            else
            {
                si.ArticleUrlGenerator = ArticleUrlGeneratorDropDownList.SelectedValue;
            }

            si.ArticleAutoShare     = (ArticleAutoShare.Checked) ? "true" : "false";
            si.EnableLoginAuhenCode = (EnableLoginAuhenCodeCheckBox.Checked) ? "true" : "false";

            si.ArticleAutoPublish = (ArticleAutoPublish.Checked) ? "true" : "false";

            si.ArticleSourceDefault = ArticleSourceDefaultTextBox.Text;
            si.EnableCache          = (EnableCache.Checked) ? "true" : "false";
            if (EnableCache.Checked)
            {
                string tmpStr = CacheTimeSpanTextBox.Text;
                Int16  tmpInt = 60;
                if (Int16.TryParse(tmpStr, out tmpInt))
                {
                    si.CacheTimeSpan = tmpInt;
                }
            }

            si.OnlyLoginUserCanVisit = OnlyLoginUserCanVisitCheckBox.Checked;
            si.StartTemplateMap      = StartTemplateMapCheckbox.Checked;
            si.SiteBuildState        = SiteStateDropDownList.SelectedValue;
            si.IPStrategy            = hddnIPStrategy.Value.Trim();
            si.AllowParentArticle    = AllowParentArticleCheckBox.Checked;
            si.EnableSingleTable     = true; //EnableSingleTable.Checked;
            si.DefaultTemplateEditor = UseVisualTemplateCheckBox.Checked ? "1" : "0";
            si.EnableHtmlTemplate    = EnableHtmlTemplate.Checked;
            txtSSOUrls.Text          = si.SSOSiteUrls = Regex.Replace(txtSSOUrls.Text, @"\s", "");
            si.Links     = txtLinks.Text.Trim();
            si.Copyright = txtCopyright.Text.Trim();

            //用户注册验证模式
            si.UserRegisterMode = drpUserRegiseterMode.SelectedValue;

            ipstrategy.Attributes["src"] = "SystemStrategy.aspx?ipstrategy=" + si.IPStrategy;

            SiteConfigs.SaveConfig(ci);
            GeneralConfigs.SaveConfig(si);

            //记录日志
            string content = string.Format("更改站点信息。");

            AddLog("站点概要", content);

            Messages.ShowMessage("系统设置保存成功!");
        }
 /// <summary>
 /// 检查登录
 /// </summary>
 /// <param name="loginName"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 private bool CheckAdmin(string loginName, string password)
 {
     return(String.Compare(loginName, SiteConfigs.GetConfig().AdministratorName, true) == 0 &&
            HelperFactory.Instance.GetHelper <SiteSettingHelper>().AdminPasswordIsValid(password));
 }
Exemple #7
0
        /// <summary>
        /// 部门-数据赋值
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="list"></param>
        void DepartmentDataToList(DataTable dt, List <PublishCountView> list, out int total, out int total2)
        {
            total = 0; total2 = 0;
            string            siteID      = SiteConfigs.GetConfig().SiteGroupEnabled ? SiteConfigs.GetConfig().SiteID : string.Empty;
            List <Department> departments = AccountHelper.GetDepartments(siteID, We7Helper.EmptyGUID, "", new string[] { "FullName", "Name", "ParentID" });

            foreach (Department dep in departments)
            {
                PublishCountView kv = new PublishCountView();
                kv.KeyValue = dep.Name;
                foreach (DataRow dr in dt.Rows)
                {
                    Account acc = AccountHelper.GetAccount(dr["AccountID"].ToString(), new string[] { "ID", "DepartmentID" });
                    if (acc != null)
                    {
                        Department d = AccountHelper.GetDepartment(acc.DepartmentID, new string[] { "FullName", "ID", });
                        if (d != null && d.FullName.ToLower().StartsWith(dep.FullName.ToLower()))
                        {
                            kv.Count  += Int32.Parse(dr["pubcount"].ToString());
                            kv.Clicks += Int32.Parse(dr["clickcount"].ToString());
                        }
                    }
                }

                total  += kv.Count;
                total2 += kv.Clicks;
                list.Add(kv);
            }

            list.Sort(new DinoComparer());
        }
Exemple #8
0
        public override void InitControl()
        {
            string keyword  = Control.Params["keyword"];
            string format   = Control.Params["format"];
            string parentId = Control.Params["parentId"];
            string role     = Control.Params["role"];

            List <Department> departments;
            string            siteID = SiteConfigs.GetConfig().SiteGroupEnabled ? SiteConfigs.GetConfig().SiteID : string.Empty;

            if (String.Compare("true", format, true) == 0)
            {
                departments = helper.GetDepartmentTreeWithFormat(siteID, parentId);
            }
            else
            {
                departments = helper.GetDepartmentTree(siteID, parentId);
            }

            ddlDepartment.DataSource     = departments;
            ddlDepartment.DataTextField  = "Name";
            ddlDepartment.DataValueField = "ID";
            ddlDepartment.DataBind();
            ddlDepartment.Items.Insert(0, new ListItem("请选择", ""));

            string val = Value as string;

            if (String.IsNullOrEmpty(val))
            {
                if (CurrentAccount != null)
                {
                    foreach (ListItem item in ddlDepartment.Items)
                    {
                        item.Selected = item.Value == CurrentAccount.DepartmentID;
                    }
                }
            }
            else
            {
                ddlDepartment.SelectedValue = val;
            }

            if (!String.IsNullOrEmpty(role) && Security.CurrentAccountID != We7Helper.EmptyGUID)
            {
                List <string> actids = helper.GetRolesOfAccount(Security.CurrentAccountID);
                bool          flag   = false;
                if (actids != null)
                {
                    foreach (string s in actids)
                    {
                        if (s == role.Trim('{', '}'))
                        {
                            flag = true;
                            break;
                        }
                    }
                }
                ddlDepartment.Enabled = flag;
            }

            if (!String.IsNullOrEmpty(Control.Width))
            {
                ddlDepartment.Width = Unit.Parse(Control.Width);
            }
            if (!String.IsNullOrEmpty(Control.Height))
            {
                ddlDepartment.Height = Unit.Parse(Control.Height);
            }

            ddlDepartment.CssClass = Control.CssClass;
            if (Control.Required && !ddlDepartment.CssClass.Contains("required"))
            {
                ddlDepartment.CssClass += " required";
            }
        }
Exemple #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GeneralConfigInfo si = GeneralConfigs.GetConfig();
                if (si != null)
                {
                    if (si.IsOEM)
                    {
                        CopyrightLiteral.Text = si.Copyright;
                    }
                    else
                    {
                        CopyrightLiteral.Text = si.CopyrightOfWe7;
                    }
                }

                SiteConfigInfo sci = SiteConfigs.GetConfig();
                if (sci == null)
                {
                    Response.Write("对不起,您的系统已升级,但配置文件尚未升级,您需要对配置数据进行升级。现在升级吗?<a href='../install/upgradeconfig.aspx'><u>现在升级</u></a>");
                    Response.End();
                }
                else
                {
#if DEBUG
                    LoginNameTextBox.Text = sci.AdministratorName;
#endif
                    GenerateRandomCode();
                    if (Request["action"] != null && Request["action"].ToString() == "logout" && Request["Authenticator"] == null)
                    {
                        //记录日志
                        string content = string.Format("退出站点");
                        AddLog("站点登录", content);
                        string result = SignOut();
                        if (!string.IsNullOrEmpty(result))
                        {
                            ShowMessage("登录退出没有成功!原因:" + result);
                        }
                        else
                        {
                            SSOLogout();
                        }
                    }
                }
            }

            if (Request["user"] != null && Request["pass"] != null)
            {
                LoginAction(Request["user"].ToString(), Request["pass"].ToString());
            }

            if (Request["Authenticator"] != null && Request["accountID"] != null)
            {
                SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current);
                string     actID      = ssoRequest.AccountID;
                if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID))
                {
                    Security.SetAccountID(actID);
                    SSOLogin(ssoRequest.UserName, ssoRequest.Password);
                    GoWhere();
                }
                else if (Request["message"] != null)
                {
                    ShowMessage("登录失败!原因:" + Request["message"]);
                    return;
                }
            }
        }
Exemple #10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();
            context.Response.Clear();
            string action = context.Request["action"];
            string msg    = "success";

            if (!String.IsNullOrEmpty(action))
            {
                IAccountHelper helper = AccountFactory.CreateInstance();
                string         key    = context.Request["value"];
                action = action.Trim().ToLower();
                Account act = null;
                if (action == "user")
                {
                    act = helper.GetAccountByLoginName(key);
                    if (act != null)
                    {
                        context.Response.Write("当前用户已存在");
                        return;
                    }
                }
                if (action == "email")
                {
                    act = helper.GetAccountByEmail(key);
                    if (act != null)
                    {
                        context.Response.Write("当前Email已被注册");
                        return;
                    }
                }
                if (action == "validate")
                {
                    act = helper.GetAccount(context.Request["AccountID"], null);
                    if (act == null)
                    {
                        context.Response.Write("验证帐号不存在,请重新申请帐号!");
                    }
                    else
                    {
                        act.EmailValidate = 1;
                        act.State         = 1;
                        helper.UpdateAccount(act, new string[] { "EmailValidate", "State" });
                    }
                }
                if (action == "submit")
                {
                    Account newAccout = new Account();
                    newAccout.LoginName = context.Request["name"];
                    newAccout.Password  = context.Request["pwd"];
                    if (SiteConfigs.GetConfig().IsPasswordHashed)
                    {
                        newAccout.Password = Security.Encrypt(newAccout.Password);
                    }
                    newAccout.Email    = context.Request["email"];
                    newAccout.UserType = 1;
                    newAccout.Created  = DateTime.Now;
                    try
                    {
                        helper.AddAccount(newAccout);
                        if (SendEmail(newAccout, context.Request))
                        {
                            msg += ":email";
                        }
                    }
                    catch (Exception ex) { context.Response.Write(ex.Message); return; }
                }
            }
            context.Response.Write(msg);
        }
Exemple #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (AccountID == null || AccountID == "")
            {
                Response.Redirect(
                    "/admin/Signin.aspx?returnURL=" + Server.UrlEncode(HttpContext.Current.Request.RawUrl), true);
            }
            else if (AccountID == We7Helper.EmptyGUID)
            {
                footer_upgrade.Visible      = true;
                RebootHyperLink.NavigateUrl = We7Helper.AddParamToUrl(this.Request.RawUrl, "reboot", "true");
            }

            //GroupLinksLiteral.Text = CreateGroupLinks();
            //QuickLinksLiteral.Text = CreateQuickLinks();
            if (SiteConfigs.GetConfig().SiteGroupEnabled)
            {
                GroupHolder.Text = string.Format("<input type=\"hidden\" id=\"wdUrl\" value=\"{0}\" />", SiteConfigs.GetConfig().WDWebUrl + "/group/GetSites.aspx?json=t&AccountID=" + AccountID);
            }
            InitCopyrightLinks();
        }
Exemple #12
0
        protected void ResetDBInfo_Click(object sender, EventArgs e)
        {
            if (AdminPasswordTextBox.Text.Length < 6)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统管理员密码不能少于6位!');</script>");
                return;
            }
            if (DatabaseTextBox.Text.Length == 0 && DBTypeDropDownList.SelectedValue == "SqlServer")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>数据库名称不能为空!</script>");
                return;
            }
            if (DBTypeDropDownList.SelectedIndex == 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择数据库类型!');</script>");
                return;
            }

            try
            {
                SiteConfigInfo __configinfo;
                try
                {
                    __configinfo = SiteConfigs.GetConfig();
                }
                catch
                {
                    __configinfo = new SiteConfigInfo();
                }
                __configinfo.AdministratorKey  = Encrypt(AdminPasswordTextBox.Text);
                __configinfo.IsPasswordHashed  = true;
                __configinfo.SiteName          = WebsiteNameTextBox.Text;
                __configinfo.AdministratorName = AdminNameTextBox.Text;
                SiteConfigs.Serialize(__configinfo, Server.MapPath("~/Config/site.config"));
                Session["SystemAdminName"] = AdminNameTextBox.Text;
                Session["SystemAdminPwd"]  = AdminPasswordTextBox.Text;
            }
            catch
            { }

            string       setupDBType = SelectDB = DBTypeDropDownList.SelectedValue;
            DatabaseInfo dbi         = new DatabaseInfo();

            dbi.Server   = ServerTextBox.Text;
            dbi.Database = DatabaseTextBox.Text;
            dbi.User     = UserTextBox.Text;
            dbi.Password = PasswordTextBox.Text;
            dbi.DBFile   = DBFileNameTextBox.Text;

            BaseConfigInfo bci = Installer.GenerateConnectionString(setupDBType, dbi);

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

            if (bci.DBType == "Oracle" || bci.DBType == "MySql")
            {
                CreateNewDBCheckBox.Checked = false;
            }

            if (CreateNewDBCheckBox.Checked)
            {
                Exception ex  = null;
                int       ret = Installer.CreateDatabase(bci, out ex);

                if (ret == -1)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('数据库已经存在,请重新命名或去掉“创建新数据库”前的勾,使用已有数据库');</script>");
                    return;
                }
                if (ret == 0)
                {
                    string exceptionMsgs = We7Helper.ConvertTextToHtml(ex.Message);
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('数据库创建失败,错误原因:" + exceptionMsgs + "');</script>");
                    return;
                }
            }

            string msg = "";

            if (!Installer.CheckConnection(bci, out msg))
            {
                msg = We7Helper.ConvertTextToHtml(msg);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('连接数据库失败,请检查您填写的数据库信息。" + msg + "');</script>");
                return;
            }
            else
            {
                Response.Redirect(Server.HtmlEncode(string.Format("step4.aspx?db={0}", setupDBType)), true);
            }
        }
Exemple #13
0
        public override bool Insert(PanelContext data)
        {
            CheckModelData(data);

            Article article = new Article();

            article.ID             = GetValue <string>(data, "ID");
            article.Title          = GetValue <string>(data, "Title");
            article.Description    = GetValue <string>(data, "Description");
            article.SubTitle       = GetValue <string>(data, "SubTitle");
            article.Index          = GetValue <int>(data, "Index");
            article.AllowComments  = GetValue <int>(data, "AllowComments");
            article.Author         = GetValue <string>(data, "Author");
            article.ContentType    = GetValue <int>(data, "ContentType");
            article.ContentUrl     = GetValue <string>(data, "ContentUrl");
            article.Content        = GetValue <string>(data, "Content");
            article.KeyWord        = GetValue <string>(data, "KeyWord");
            article.DescriptionKey = GetValue <string>(data, "DescriptionKey");
            article.Overdue        = GetValue <DateTime>(data, "Overdue");
            article.OwnerID        = GetValue <string>(data, "OwnerID");
            article.Tags           = GetValue <string>(data, "Tags");
            article.PrivacyLevel   = GetValue <int>(data, "PrivacyLevel");
            article.Source         = SiteConfigs.GetConfig().SiteName;
            article.Created        = DateTime.Now;
            article.Updated        = DateTime.Now;
            article.Thumbnail      = GetValue <string>(data, "Thumbnail");
            article.ListKeys       = GetValue <string>(data, "ListKeys");
            article.ListKeys2      = GetValue <string>(data, "ListKeys2");
            article.ListKeys3      = GetValue <string>(data, "ListKeys3");
            article.ListKeys4      = GetValue <string>(data, "ListKeys4");
            article.ListKeys5      = GetValue <string>(data, "ListKeys5");

            string config, schema;

            article.ModelXml    = GetModelDataXml(data, article.ModelXml, out schema, out config);//获取模型数据
            article.ModelConfig = config;
            article.ModelSchema = schema;

            if (article.ModelXml.Length >= MaxCount)
            {
                UIHelper.Message.AppendInfo(MessageType.ERROR, "输入内容过长,请重新输入");
                Logger.WriteLine();
                Logger.WriteDate();
                Logger.Write("输入内容过长");
                Logger.Write(article.ModelXml);
                return(false);
            }

            article.ModelName = data.Model.ModelName;
            article.TableName = data.Table.Name;
            article.State     = GetValue <int>(data, "State");

            if (!String.IsNullOrEmpty(article.OwnerID))
            {
                Channel ch = ChannelHelper.GetChannel(article.OwnerID, null);
                if (ch != null)
                {
                    article.ChannelFullUrl  = ch.FullUrl;
                    article.ChannelName     = ch.FullPath;
                    article.FullChannelPath = ch.FullPath;
                    article.State           = ch.Process != null && ch.Process == "1" ? 2 : article.State;
                }
            }
            int type = 0;

            article.EnumState = StateMgr.StateProcess(article.EnumState, EnumLibrary.Business.ArticleType, type);

            article.AccountID = GetValue <string>(data, "AccountID");
            if (String.IsNullOrEmpty(article.AccountID))
            {
                try
                {
                    article.AccountID = Security.CurrentAccountID;
                }
                catch { }
            }

            ArticleHelper.AddArticle(article);
            ArticleIndexHelper.InsertData(article.ID, 0);
            return(true);
        }
Exemple #14
0
        public override bool Update(PanelContext data)
        {
            try
            {
                CheckModelData(data);

                Article article = ArticleHelper.GetArticle(GetValue <string>(data, "ID"));
                if (article == null)
                {
                    Insert(data);
                }
                else
                {
                    article.Title          = GetValue <string>(data, "Title");
                    article.Description    = GetValue <string>(data, "Description");
                    article.SubTitle       = GetValue <string>(data, "SubTitle");
                    article.Index          = GetValue <int>(data, "Index");
                    article.AllowComments  = GetValue <int>(data, "AllowComments");
                    article.Author         = GetValue <string>(data, "Author");
                    article.ContentType    = GetValue <int>(data, "ContentType");
                    article.ContentUrl     = GetValue <string>(data, "ContentUrl");
                    article.Content        = GetValue <string>(data, "Content");
                    article.KeyWord        = GetValue <string>(data, "KeyWord");
                    article.DescriptionKey = GetValue <string>(data, "DescriptionKey");
                    article.Overdue        = GetValue <DateTime>(data, "Overdue");
                    article.IsShow         = GetValue <int>(data, "IsShow");
                    article.Tags           = GetValue <string>(data, "Tags");
                    article.OwnerID        = GetValue <string>(data, "OwnerID");
                    article.PrivacyLevel   = GetValue <int>(data, "PrivacyLevel");
                    article.Source         = SiteConfigs.GetConfig().SiteName;
                    article.ListKeys       = GetValue <string>(data, "ListKeys");
                    article.ListKeys2      = GetValue <string>(data, "ListKeys2");
                    article.ListKeys3      = GetValue <string>(data, "ListKeys3");
                    article.ListKeys4      = GetValue <string>(data, "ListKeys4");
                    article.ListKeys5      = GetValue <string>(data, "ListKeys5");

                    article.State = GetValue <int>(data, "State");
                    if (!String.IsNullOrEmpty(article.OwnerID))
                    {
                        Channel ch = ChannelHelper.GetChannel(article.OwnerID, null);
                        if (ch != null)
                        {
                            article.ChannelFullUrl  = ch.FullUrl;
                            article.ChannelName     = ch.FullPath;
                            article.FullChannelPath = ch.FullPath;
                        }
                    }
                    int type = 0;
                    article.EnumState = StateMgr.StateProcess(article.EnumState, EnumLibrary.Business.ArticleType, type);

                    article.Updated = DateTime.Now;

                    string config, schema;
                    article.ModelXml = GetModelDataXml(data, article.ModelXml, out schema, out config);//获取模型数据

                    if (article.ModelXml.Length >= MaxCount)
                    {
                        UIHelper.Message.AppendInfo(MessageType.ERROR, "输入内容过长,请重新输入");
                        Logger.WriteLine();
                        Logger.WriteDate();
                        Logger.Write("输入内容过长");
                        Logger.Write(article.ModelXml);
                        return(false);
                    }
                    article.ModelConfig = config;
                    article.ModelSchema = schema;

                    article.ModelName = data.Model.ModelName;
                    article.TableName = data.Table.Name;
                    string[] updatefields = new string[] { "OwnerID", "ChannelFullUrl", "ChannelName", "FullChannelPath", "Description", "Title", "Content", "ListKeys", "ListKeys2", "ListKeys3", "ListKeys4", "ListKeys5", "Updated", "Index", "EnumState", "Source", "AllowComments", "Author", "State", "IsShow", "SubTitle", "ContentUrl", "ContentType", "Overdue", "Tags", "KeyWord", "DescriptionKey", "ModelXml", "ModelName", "TableName", "ModelConfig", "ModelSchema" };
                    ArticleHelper.UpdateArticle(article, updatefields);

                    // 往全文检索里更新数据
                    ArticleIndexHelper.InsertData(article.ID, 1);
                }
            }
            catch { }

            return(true);
        }