Пример #1
0
        /// <summary>
        /// 页面请求事件处理
        /// </summary>
        /// <param name="sender">事件的源</param>
        /// <param name="e">包含事件数据的 EventArgs</param>
        private void ReUrl_BeginRequest(object sender, EventArgs e)
        {
            HttpContext context = ((HttpApplication)sender).Context;
            string requestPath = context.Request.Path; //获得当前页面,包含目录
            string requestPage = requestPath.Substring(requestPath.LastIndexOf("/")); //获得当前页面,不包含目录
            Entity.siteconfig siteConfig = new BLL.siteconfigBll().loadConfig(Utils.GetXmlMapPath(SysKeys.FILE_SITE_XML_CONFING)); //获得站点配置信息

            bool isRewritePath = IsUrlRewrite(siteConfig.webpath, requestPath); //排除不需要URL重写的目录
            switch (siteConfig.staticstatus)
            {
                case 0: //关闭重写
                    if (isRewritePath && IsAspxFile(requestPath))
                    {
                        context.RewritePath(siteConfig.webpath + SysKeys.DIRECTORY_REWRITE_ASPX + "/" + requestPage);
                    }
                    break;
                case 1: //伪URL重写
                    if (isRewritePath)
                    {
                        RewriteUrl(context, siteConfig.webpath, requestPath, requestPage);
                    }
                    break;
                case 2: //全静态
                    if (requestPath.ToLower().Equals("/index.aspx"))
                    {
                        context.RewritePath(siteConfig.webpath + SysKeys.DIRECTORY_REWRITE_HTML + "/index." + siteConfig.staticextension);
                    }
                    break;
            }
        }
Пример #2
0
        //生成首页静态
        public static void CreateIndexHtml()
        {
            Entity.siteconfig config = new BLL.siteconfigBll().loadConfig(Utils.GetXmlMapPath(SysKeys.FILE_SITE_XML_CONFING));
            string urlPath = string.Format("{0}{1}/{2}", config.webpath, SysKeys.DIRECTORY_REWRITE_ASPX, "index.aspx"); //文件相对路径
            string htmlPath = string.Format("{0}{1}/{2}", config.webpath, SysKeys.DIRECTORY_REWRITE_HTML, "index." + config.staticextension); //保存相对路径
            //检查文件是否存在
            if (!File.Exists(Utils.GetMapPath(urlPath)))
            {

            }
            Stopwatch watch = new Stopwatch(); //测量时间
            watch.Start();
            StringWriter sw = new StringWriter();
            HttpContext.Current.Server.Execute(urlPath, sw);
            File.WriteAllText(Utils.GetMapPath(htmlPath), sw.ToString(), Encoding.UTF8);
            watch.Stop();
            //watch.Elapsed
            sw.Close();
            sw.Dispose();
        }
 private void sys_channel_validate(HttpContext context)
 {
     string channelname = SysRequest.GetFormString("channelname");
     string oldname = SysRequest.GetFormString("oldname");
     if (string.IsNullOrEmpty(channelname))
     {
         context.Response.Write("false");
         return;
     }
     //检查是否与站点根目录下的目录同名
     Model.siteconfig siteConfig = new BLL.siteconfigBll().loadConfig(Utils.GetXmlMapPath("Configpath"));
     DirectoryInfo dirInfo = new DirectoryInfo(Utils.GetMapPath(siteConfig.webpath));
     foreach (DirectoryInfo dir in dirInfo.GetDirectories())
     {
         if (channelname.ToLower() == dir.Name)
         {
             context.Response.Write("false");
             return;
         }
     }
     //检查是否修改操作
     if (channelname == oldname)
     {
         context.Response.Write("true");
         return;
     }
     //检查Key是否与已存在
     BLL.sys_channel bll = new BLL.sys_channel();
     if (bll.Exists(channelname))
     {
         context.Response.Write("false");
         return;
     }
     context.Response.Write("true");
     return;
 }
Пример #4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text.Trim();
            string userPwd = txtUserPwd.Text.Trim();
            string code = txtCode.Text.Trim();

            if (userName.Equals("") || userPwd.Equals(""))
            {
                lblTip.Visible = true;
                lblTip.Text = "请输入用户名或密码";
                return;
            }
            if (code.Equals(""))
            {
                lblTip.Visible = true;
                lblTip.Text = "请输入验证码";
                return;
            }
            if (Session[SysKeys.SESSION_CODE] == null)
            {
                lblTip.Visible = true;
                lblTip.Text = "系统找不到验证码";
                return;
            }
            if (code.ToLower() != Session[SysKeys.SESSION_CODE].ToString().ToLower())
            {
                lblTip.Visible = true;
                lblTip.Text = "验证码输入不正确";
                return;
            }
            BLL.ManagerBll bll = new BLL.ManagerBll();
            Entity.Manager model = bll.GetEntityByNameAndPwd(userName, DESEncrypt.Encrypt(userPwd));
            if (model == null)
            {
                lblTip.Visible = true;
                lblTip.Text = "用户名或密码有误";
                return;
            }
            Session[SysKeys.SESSION_ADMIN_INFO] = model;
            Session.Timeout = 45;
            //写入登录日志
            Entity.siteconfig siteConfig = new BLL.siteconfigBll().loadConfig(Utils.GetXmlMapPath(SysKeys.FILE_SITE_XML_CONFING));
            if (siteConfig.logstatus > 0)
            {
                Entity.manager_log modelLog = new Entity.manager_log();
                modelLog.user_id = model.ID;
                modelLog.user_name = model.UserName;
                modelLog.action_type = "login";
                modelLog.note = "用户登录";
                modelLog.login_ip = SysRequest.GetIP();
                modelLog.login_time = DateTime.Now;
                new BLL.manager_log().Add(modelLog);
            }
            //写入Cookies
            if (cbRememberId.Checked)
            {
                Utils.WriteCookie("DTRememberName", model.UserName, 14400);
            }
            else
            {
                Utils.WriteCookie("DTRememberName", model.UserName, -14400);
            }
            Utils.WriteCookie("AdminName", "DTcms", model.UserName);
            Utils.WriteCookie("AdminPwd", "DTcms", model.UserPassword);
            Response.Redirect("index.aspx");
            return;
        }