示例#1
0
 private void MarkTemplates(string dirName)
 {
     BLL.url_rewrite bll = new BLL.url_rewrite();
     List<Model.url_rewrite> ls = bll.GetList("");
     //业务模块目录
     string pluginPath = Utils.GetMapPath("../../plugins/" + dirName + "/templet/");
     if (!Directory.Exists(pluginPath))
     {
         return;
     }
     DirectoryInfo dirInfo = new DirectoryInfo(pluginPath);
     foreach (FileInfo file in dirInfo.GetFiles())
     {
         if (!file.Name.StartsWith("_") && file.Name.EndsWith(".html"))
         {
             foreach (Model.url_rewrite model in ls)
             {
                 if (file.Name.ToLower() == model.templet && !string.IsNullOrEmpty(model.inherit))
                 {
                     //生成模板文件
                     PageTemplate.GetTemplate(siteConfig.webpath, "plugins/" + dirName, "templet", model.templet, model.page, model.inherit, 0, 1);
                 }
             }
         }
     }
 }
示例#2
0
        private bool DoAdd()
        {
            BLL.url_rewrite bll = new BLL.url_rewrite();
            Model.url_rewrite model = new Model.url_rewrite();

            model.name = txtName.Text.Trim();
            model.type = ddlType.SelectedValue;
            model.channel = ddlChannel.SelectedValue;
            model.page = txtPage.Text.Trim();
            model.inherit = txtInherit.Text.Trim();
            model.templet = txtTemplet.Text.Trim();
            //添加URL重写节点
            List<Model.url_rewrite_item> items = new List<Model.url_rewrite_item>();
            string[] itemPathArr = Request.Form.GetValues("itemPath");
            string[] itemPatternArr = Request.Form.GetValues("itemPattern");
            string[] itemQuerystringArr = Request.Form.GetValues("itemQuerystring");
            if (itemPathArr != null && itemPatternArr != null && itemQuerystringArr != null)
            {
                for (int i = 0; i < itemPathArr.Length; i++)
                {
                    items.Add(new Model.url_rewrite_item { path = itemPathArr[i], pattern = itemPatternArr[i], querystring = itemQuerystringArr[i] });
                }
            }
            model.url_rewrite_items = items;

            if (bll.Add(model))
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加URL配置信息:" + model.name); //记录日志
                return true;
            }
            return false;
        }
示例#3
0
文件: search.cs 项目: egojit/B2C
 //查找匹配的URL
 private string get_url_rewrite(string channel_id, int id)
 {
     BLL.url_rewrite bll = new BLL.url_rewrite();
     Model.url_rewrite model = bll.GetInfo(channel_id, "detail");
     if (model != null)
     {
         return linkurl(model.name, id);
     }
     return "";
 }
示例#4
0
        /// <summary>
        /// 获取生成静态地址
        /// </summary>
        /// <param name="context"></param>
        public void getpublishsite(HttpContext context)
        {
            string lang = MXRequest.GetQueryString("lang");
            string name = MXRequest.GetQueryString("name");
            string type = MXRequest.GetQueryString("type");

            StringBuilder sbjson = new StringBuilder();
            //获得URL配置列表
            BLL.url_rewrite bll = new BLL.url_rewrite();
            List<Model.url_rewrite> ls = (!string.IsNullOrEmpty(type)) ? bll.GetList(name, type) : bll.GetList(name);
            string linkurl = string.Empty;
            sbjson.Append("[");
            foreach (Model.url_rewrite modeltrewrite in ls)
            {
                if (modeltrewrite.url_rewrite_items.Count > 0)
                {
                    if (modeltrewrite.channel == string.Empty || modeltrewrite.channel == name)
                    {
                        //遍历URL字典的子节点
                        foreach (Model.url_rewrite_item item in modeltrewrite.url_rewrite_items)
                        {
                            if (item.querystring == string.Empty)
                            {
                                linkurl = string.Format("{0}/{1}/{2}", MXKeys.DIRECTORY_REWRITE_ASPX, lang, modeltrewrite.page);
                                string HTMLPattern = string.Format("{0}/{1}/{2}", MXKeys.DIRECTORY_REWRITE_HTML, lang, Utils.GetUrlExtension(item.pattern, config.staticextension)); //替换扩展名
                                if (sbjson.ToString().Length > 1)
                                    sbjson.Append(",");
                                sbjson.AppendFormat(urlstr, config.webpath, lang, linkurl, HTMLPattern);
                            }
                            else
                            {
                                if (sbjson.ToString().Length > 1)
                                    sbjson.Append(",");
                                switch (modeltrewrite.type.ToLower())
                                {
                                    case "list":
                                        sbjson.Append(GetArticleUrlList(lang, name, modeltrewrite.page, item.pattern, item.path, item.querystring, objchannel.GetPageSize(name)));
                                        break;
                                    case "detail":
                                        sbjson.Append(GetDetailUrlList(lang, name, modeltrewrite.page, item.pattern, item.path, item.querystring));
                                        break;
                                    case "category":
                                        sbjson.Append(GetCategoryUrlList(lang, name, modeltrewrite.page, item.pattern, item.path, item.querystring, objchannel.GetPageSize(name)));
                                        break;
                                }
                            }
                        }
                    }
                }
            }
            sbjson.Append("]");
            context.Response.Write(sbjson.ToString());
        }
 //删除操作
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     BLL.url_rewrite bll = new BLL.url_rewrite();
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         string urlName = ((HiddenField)rptList.Items[i].FindControl("hideName")).Value;
         CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
         if (cb.Checked)
         {
             bll.Remove("name", urlName);
         }
     }
     JscriptMsg("URL规则删除成功啦!", "url_rewrite_list.aspx", "Success");
 }
 private bool DoEdit(string _urlName)
 {
     BLL.url_rewrite bll = new BLL.url_rewrite();
     Model.url_rewrite model = bll.GetInfo(_urlName);
     model.name = txtName.Text.Trim();
     model.path = txtPath.Text.Trim();
     model.pattern = txtPattern.Text.Trim();
     model.page = txtPage.Text.Trim();
     model.querystring = txtQueryString.Text.Trim();
     model.templet = txtTemplet.Text.Trim();
     model.channel = txtChannel.Text.Trim();
     model.type = ddlType.SelectedValue;
     model.inherit = txtInherit.Text.Trim();
     return bll.Edit(model);
 }
 private void ShowInfo(string _urlName)
 {
     BLL.url_rewrite bll = new BLL.url_rewrite();
     Model.url_rewrite model = bll.GetInfo(_urlName);
     txtName.Text = model.name;
     txtName.ReadOnly = true;
     txtPath.Text = model.path;
     txtPattern.Text = model.pattern;
     txtPage.Text = model.page;
     txtQueryString.Text = model.querystring;
     txtTemplet.Text = model.templet;
     txtChannel.Text = model.channel;
     ddlType.SelectedValue = model.type;
     txtInherit.Text = model.inherit;
 }
示例#8
0
 //删除操作
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("site_url_rewrite", DTEnums.ActionEnum.Delete.ToString()); //检查权限
     BLL.url_rewrite bll = new BLL.url_rewrite();
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         string urlName = ((HiddenField)rptList.Items[i].FindControl("hideName")).Value;
         CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
         if (cb.Checked)
         {
             bll.Remove("name", urlName);
         }
     }
     AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除URL配置信息"); //记录日志
     JscriptMsg("URL配置删除成功!", "url_rewrite_list.aspx", "Success");
 }
        private void ShowInfo(string _urlName)
        {
            BLL.url_rewrite bll = new BLL.url_rewrite();
            Model.url_rewrite model = bll.GetInfo(_urlName);

            txtName.Text = model.name;
            txtName.ReadOnly = true;
            ddlType.SelectedValue = model.type;
            ddlChannel.SelectedValue = model.channel;
            txtPage.Text = model.page;
            txtInherit.Text = model.inherit;
            txtTemplet.Text = model.templet;
            //绑定URL配置列表
            rptList.DataSource = model.url_rewrite_items;
            rptList.DataBind();
        }
示例#10
0
 //删除操作
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("sys_channel", DTEnums.ActionEnum.Delete.ToString()); //检查权限
     Egojit.BLL.sys_channel bll = new Egojit.BLL.sys_channel();
     BLL.url_rewrite bll2 = new BLL.url_rewrite();
     //批量删除
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
         CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
         if (cb.Checked)
         {
             bll.Delete(id);
             //删除URL映射表
             bll2.Remove("channel", id.ToString());
         }
     }
     JscriptMsg("批量删除成功啦!", Utils.CombUrlTxt("sys_channel_list.aspx", "keywords={0}", txtKeywords.Text.Trim()), "Success", "parent.loadChannelTree");
 }
        /// <summary>
        /// 生成全部模板
        /// </summary>
        public static void MarkTemplates(string buildPath, string skinName, siteconfig siteconfig)
        {
            //取得ASP目录下的所有文件
            string fullDirPath = Utils.GetMapPath(string.Format("{0}aspx/{1}/", siteconfig.webpath, buildPath));

            //获得URL配置列表
            BLL.url_rewrite          bll = new BLL.url_rewrite();
            List <Model.url_rewrite> ls  = bll.GetList("");

            DirectoryInfo dirFile = new DirectoryInfo(fullDirPath);

            //删除不属于URL映射表里的文件,防止冗余
            if (Directory.Exists(fullDirPath))
            {
                foreach (FileInfo file in dirFile.GetFiles())
                {
                    //检查文件
                    //Model.url_rewrite modelt = ls.Find(p => p.page.ToLower() == file.Name.ToLower());
                    //if (modelt == null)
                    //{
                    file.Delete();
                    //}
                }
            }

            //遍历URL配置列表
            foreach (Model.url_rewrite modelt in ls)
            {
                //如果URL配置对应的模板文件存在则生成
                string fullPath = Utils.GetMapPath(string.Format("{0}templates/{1}/{2}", siteconfig.webpath, skinName, modelt.templet));
                if (File.Exists(fullPath))
                {
                    PageTemplate.GetTemplate(siteconfig.webpath, "templates", skinName, modelt.templet, modelt.page, modelt.inherit, buildPath, 1);
                }
            }
        }
示例#12
0
        private void urlrewrite_name_validate(HttpContext context)
        {
            string new_name = DTRequest.GetString("param");
            string old_name = DTRequest.GetString("old_name");

            if (string.IsNullOrEmpty(new_name))
            {
                context.Response.Write("{ \"info\":\"名称不可为空!\", \"status\":\"n\" }");
                return;
            }
            if (new_name.ToLower() == old_name.ToLower())
            {
                context.Response.Write("{ \"info\":\"该名称可使用\", \"status\":\"y\" }");
                return;
            }
            BLL.url_rewrite bll = new BLL.url_rewrite();
            if (bll.Exists(new_name))
            {
                context.Response.Write("{ \"info\":\"该名称已被使用,请更换!\", \"status\":\"n\" }");
                return;
            }
            context.Response.Write("{ \"info\":\"该名称可使用\", \"status\":\"y\" }");
            return;
        }
示例#13
0
        /// <summary>
        /// 返回URL重写统一链接地址
        /// </summary>
        public string linkurl(string _key, params object[] _params)
        {
            Hashtable ht = new BLL.url_rewrite().GetList(); //获得URL配置列表
            Model.url_rewrite model = ht[_key] as Model.url_rewrite; //查找指定的URL配置节点

            //如果不存在该节点则返回空字符串
            if (model == null)
            {
                return string.Empty;
            }

            string requestDomain = HttpContext.Current.Request.Url.Authority.ToLower(); //获得来源域名含端口号
            string requestFirstPath = GetFirstPath();//获得二级目录(不含站点安装目录)
            string linkStartString = string.Empty; //链接前缀

            //检查是否与绑定的域名或者与默认频道分类的目录匹配
            if (SiteDomains.GetSiteDomains().CategoryDirs.ContainsValue(requestDomain))
            {
                linkStartString = "/";
            }

            else if (requestFirstPath == string.Empty || requestFirstPath == SiteDomains.GetSiteDomains().DefaultPath)
            {
                linkStartString = config.webpath;
            }
            else
            {
                linkStartString = config.webpath + requestFirstPath + "/";
            }
            //如果URL字典表达式不需要重写则直接返回
            if (model.url_rewrite_items.Count == 0)
            {
                //检查网站重写状态
                if (config.staticstatus > 0)
                {
                    if (_params.Length > 0)
                    {
                        return linkStartString + GetUrlExtension(model.page, config.staticextension) + string.Format("{0}", _params);
                    }
                    else
                    {
                        return linkStartString + GetUrlExtension(model.page, config.staticextension);
                    }
                }
                else
                {
                    if (_params.Length > 0)
                    {
                        return linkStartString + model.page + string.Format("{0}", _params);
                    }
                    else
                    {
                        return linkStartString + model.page;
                    }
                }
            }
            //否则检查该URL配置节点下的子节点
            foreach (Model.url_rewrite_item item in model.url_rewrite_items)
            {
                //如果参数个数匹配
                if (IsUrlMatch(item, _params))
                {
                    //检查网站重写状态
                    if (config.staticstatus > 0)
                    {
                        return linkStartString + string.Format(GetUrlExtension(item.path, config.staticextension), _params);
                    }
                    else
                    {
                        string queryString = Regex.Replace(string.Format(item.path, _params), item.pattern, item.querystring, RegexOptions.None | RegexOptions.IgnoreCase);
                        if (queryString.Length > 0)
                        {
                            queryString = "?" + queryString;
                        }
                        return linkStartString + model.page + queryString;
                    }
                }
            }

            return string.Empty;
        }
示例#14
0
        /// <summary>
        /// 获取生成静态地址
        /// </summary>
        /// <param name="context"></param>
        public void getpublishsite(HttpContext context)
        {
            string lang = PLRequest.GetQueryString("lang");
            string name = PLRequest.GetQueryString("name");
            string type = PLRequest.GetQueryString("type");

            StringBuilder sbjson = new StringBuilder();


            //获得URL配置列表
            BLL.url_rewrite          bll = new BLL.url_rewrite();
            List <Model.url_rewrite> ls  = (!string.IsNullOrEmpty(type)) ? bll.GetList(name, type) : bll.GetList(name);
            string linkurl = string.Empty;

            sbjson.Append("[");
            if (type == "indexlist")
            {
                #region 针对特殊需求
                List <Model.url_rewrite> ls2 = (!string.IsNullOrEmpty("list")) ? bll.GetList(name, "list") : bll.GetList(name, "list");
                foreach (Model.url_rewrite modeltrewrite2 in ls2)
                {
                    if (modeltrewrite2.url_rewrite_items.Count > 0)
                    {
                        if (modeltrewrite2.channel == string.Empty || modeltrewrite2.channel == name)
                        {
                            //遍历URL字典的子节点
                            foreach (Model.url_rewrite_item item2 in modeltrewrite2.url_rewrite_items)
                            {
                                if (sbjson.ToString().Length > 1)
                                {
                                    sbjson.Append(",");
                                }
                                switch (modeltrewrite2.type.ToLower())
                                {
                                case "list":
                                    sbjson.Append(GetArticleIndexUrlList(lang, name, modeltrewrite2.page, item2.pattern, item2.path, item2.querystring, Utils.StrToInt(modeltrewrite2.pagesize, 0)));
                                    break;
                                }
                            }
                        }
                    }
                }
                #endregion
            }
            else
            {
                foreach (Model.url_rewrite modeltrewrite in ls)
                {
                    if (modeltrewrite.url_rewrite_items.Count > 0)
                    {
                        if (modeltrewrite.channel == string.Empty || modeltrewrite.channel == name)
                        {
                            //遍历URL字典的子节点
                            foreach (Model.url_rewrite_item item in modeltrewrite.url_rewrite_items)
                            {
                                if (item.querystring == string.Empty)
                                {
                                    linkurl = string.Format("{0}/{1}/{2}", PLKeys.DIRECTORY_REWRITE_ASPX, lang, modeltrewrite.page);
                                    string HTMLPattern = string.Format("{0}/{1}/{2}", PLKeys.DIRECTORY_REWRITE_HTML, lang, Utils.GetUrlExtension(item.pattern, config.staticextension)); //替换扩展名
                                    if (sbjson.ToString().Length > 1)
                                    {
                                        sbjson.Append(",");
                                    }
                                    sbjson.AppendFormat(urlstr, config.webpath, lang, linkurl, HTMLPattern);
                                }
                                else
                                {
                                    if (sbjson.ToString().Length > 1)
                                    {
                                        sbjson.Append(",");
                                    }
                                    switch (modeltrewrite.type.ToLower())
                                    {
                                    case "list":
                                        sbjson.Append(GetArticleUrlList(lang, name, modeltrewrite.page, item.pattern, item.path, item.querystring, Utils.StrToInt(modeltrewrite.pagesize, 0)));
                                        break;

                                    case "detail":
                                        sbjson.Append(GetDetailUrlList(lang, name, modeltrewrite.page, item.pattern, item.path, item.querystring));
                                        break;

                                    case "category":
                                        sbjson.Append(GetCategoryUrlList(lang, name, modeltrewrite.page, item.pattern, item.path, item.querystring, Utils.StrToInt(modeltrewrite.pagesize, 0)));
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            sbjson.Append("]");
            context.Response.Write(sbjson.ToString());
        }
示例#15
0
        /// <summary>
        /// 生成全部模板
        /// </summary>
        private void MarkTemplates(string buildPath, string skinName)
        {
            //取得ASP目录下的所有文件
            string fullDirPath = Utils.GetMapPath(string.Format("{0}aspx/{1}/", siteConfig.webpath, buildPath));
            //获得URL配置列表
            BLL.url_rewrite bll = new BLL.url_rewrite();
            List<Model.url_rewrite> ls = bll.GetList("");

            DirectoryInfo dirFile = new DirectoryInfo(fullDirPath);
            //删除不属于URL映射表里的文件,防止冗余
            if (Directory.Exists(fullDirPath))
            {
                foreach (FileInfo file in dirFile.GetFiles())
                {
                    //检查文件
                    //Model.url_rewrite modelt = ls.Find(p => p.page.ToLower() == file.Name.ToLower());
                    //if (modelt == null)
                    //{
                    file.Delete();
                    //}
                }
            }

            //遍历URL配置列表
            foreach (Model.url_rewrite modelt in ls)
            {
                //如果URL配置对应的模板文件存在则生成
                string fullPath = Utils.GetMapPath(string.Format("{0}templates/{1}/{2}", siteConfig.webpath, skinName, modelt.templet));
                if (File.Exists(fullPath))
                {
                    PageTemplate.GetTemplate(siteConfig.webpath, "templates", skinName, modelt.templet, modelt.page, modelt.inherit, buildPath, modelt.channel, modelt.pagesize, 1);
                }
            }
        }
        private bool DoAdd()
        {
            Model.channel model = new Model.channel();
            BLL.channel   bll   = new BLL.channel();

            model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0);
            model.name        = txtName.Text.Trim();
            model.title       = txtTitle.Text.Trim();
            if (cbIsAlbums.Checked == true)
            {
                model.is_albums = 1;
            }
            if (cbIsAttach.Checked == true)
            {
                model.is_attach = 1;
            }
            if (cbIsGroupPrice.Checked == true)
            {
                model.is_group_price = 1;
            }
            model.page_size = Utils.StrToInt(txtPageSize.Text.Trim(), 10);
            model.sort_id   = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            //添加频道扩展字段
            List <Model.channel_field> ls = new List <Model.channel_field>();

            for (int i = 0; i < cblAttributeField.Items.Count; i++)
            {
                if (cblAttributeField.Items[i].Selected)
                {
                    ls.Add(new Model.channel_field {
                        field_id = Utils.StrToInt(cblAttributeField.Items[i].Value, 0)
                    });
                }
            }
            model.channel_fields = ls;

            if (bll.Add(model) < 1)
            {
                return(false);
            }

            #region 保存URL配置
            BLL.url_rewrite urlBll = new BLL.url_rewrite();
            urlBll.Remove("channel", model.name); //先删除
            string[] itemTypeArr    = Request.Form.GetValues("item_type");
            string[] itemNameArr    = Request.Form.GetValues("item_name");
            string[] itemPageArr    = Request.Form.GetValues("item_page");
            string[] itemTempletArr = Request.Form.GetValues("item_templet");
            string[] itemRewriteArr = Request.Form.GetValues("item_rewrite");

            if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemRewriteArr != null)
            {
                if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) &&
                    (itemPageArr.Length == itemTempletArr.Length) && (itemTempletArr.Length == itemRewriteArr.Length))
                {
                    for (int i = 0; i < itemTypeArr.Length; i++)
                    {
                        Model.url_rewrite urlModel = new Model.url_rewrite();
                        urlModel.name    = itemNameArr[i].Trim();
                        urlModel.type    = itemTypeArr[i].Trim();
                        urlModel.page    = itemPageArr[i].Trim();
                        urlModel.inherit = GetInherit(urlModel.type);
                        urlModel.templet = itemTempletArr[i].Trim();
                        urlModel.channel = model.name;

                        List <Model.url_rewrite_item> itemLs = new List <Model.url_rewrite_item>();
                        string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串
                        for (int j = 0; j < urlRewriteArr.Length; j++)
                        {
                            string[] urlItemArr = urlRewriteArr[j].Split(',');
                            if (urlItemArr.Length == 3)
                            {
                                itemLs.Add(new Model.url_rewrite_item {
                                    path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2]
                                });
                            }
                        }
                        urlModel.url_rewrite_items = itemLs;
                        urlBll.Add(urlModel);
                    }
                }
            }
            #endregion

            AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加频道" + model.title); //记录日志
            return(true);
        }
示例#17
0
        /// <summary>
        /// 返回URL重写统一链接地址
        /// </summary>
        public string linkurl(string _key, params object[] _params)
        {
            Hashtable ht = new BLL.url_rewrite().GetList();          //获得URL配置列表

            Model.url_rewrite model = ht[_key] as Model.url_rewrite; //查找指定的URL配置节点

            //如果不存在该节点则返回空字符串
            if (model == null)
            {
                return(string.Empty);
            }

            string requestDomain   = HttpContext.Current.Request.Url.Authority.ToLower(); //获得来源域名含端口号
            string requestPath     = HttpContext.Current.Request.RawUrl.ToLower();        //当前的URL地址
            string linkStartString = GetLinkStartString(requestPath, requestDomain);      //链接前缀

            //如果URL字典表达式不需要重写则直接返回
            if (model.url_rewrite_items.Count == 0)
            {
                //检查网站重写状态
                if (config.staticstatus > 0)
                {
                    if (_params.Length > 0)
                    {
                        return(linkStartString + GetUrlExtension(model.page, config.staticextension) + string.Format("{0}", _params));
                    }
                    else
                    {
                        return(linkStartString + GetUrlExtension(model.page, config.staticextension));
                    }
                }
                else
                {
                    if (_params.Length > 0)
                    {
                        return(linkStartString + model.page + string.Format("{0}", _params));
                    }
                    else
                    {
                        return(linkStartString + model.page);
                    }
                }
            }
            //否则检查该URL配置节点下的子节点
            foreach (Model.url_rewrite_item item in model.url_rewrite_items)
            {
                //如果参数个数匹配
                if (IsUrlMatch(item, _params))
                {
                    //检查网站重写状态
                    if (config.staticstatus > 0)
                    {
                        return(linkStartString + string.Format(GetUrlExtension(item.path, config.staticextension), _params));
                    }
                    else
                    {
                        string queryString = Regex.Replace(string.Format(item.path, _params), item.pattern, item.querystring, RegexOptions.None | RegexOptions.IgnoreCase);
                        if (queryString.Length > 0)
                        {
                            queryString = "?" + queryString;
                        }
                        return(linkStartString + model.page + queryString);
                    }
                }
            }

            return(string.Empty);
        }
示例#18
0
 /// <summary>
 /// 生成全部模板
 /// </summary>
 private void MarkTemplates(string skinName)
 {
     //取得ASP目录下的所有文件
     DirectoryInfo dirFile = new DirectoryInfo(Utils.GetMapPath(siteConfig.webpath + "aspx/"));
     //获得URL映射列表
     BLL.url_rewrite bll = new BLL.url_rewrite();
     List<Model.url_rewrite> ls = bll.GetList("");
     //删除不属于URL映射表里的文件,防止冗余
     foreach (FileInfo file in dirFile.GetFiles())
     {
         //检查文件
         Model.url_rewrite model2 = ls.Find(p => p.page.ToLower() == file.Name.ToLower());
         if (model2 == null)
         {
             file.Delete();
         }
     }
     //遍历站点目录的templates文件夹下的模板文件
     DirectoryInfo dirInfo = new DirectoryInfo(Utils.GetMapPath(siteConfig.webpath + @"templates/" + skinName));
     foreach (FileInfo file in dirInfo.GetFiles())
     {
         if (!file.Name.StartsWith("_") && file.Name.EndsWith(".html"))
         {
             //查找相对应的继承类名
             foreach (Model.url_rewrite model in ls)
             {
                 if (file.Name.ToLower()==model.templet && !string.IsNullOrEmpty(model.inherit))
                 {
                     //检查频道ID
                     int channelId = Utils.StrToInt(model.channel, 0);
                     //生成模板文件
                     PageTemplate.GetTemplate(siteConfig.webpath, "templates", skinName, model.templet, model.page, model.inherit, channelId, 1);
                 }
             }
         }
     }
 }
示例#19
0
 //构造函数
 private SiteUrls()
 {
     Urls = new ArrayList();
     BLL.url_rewrite bll = new BLL.url_rewrite();
     List<Model.url_rewrite> ls = bll.GetList("");
     foreach(Model.url_rewrite model in ls)
     {
         foreach (Model.url_rewrite_item item in model.url_rewrite_items)
         {
             item.querystring = item.querystring.Replace("^", "&");
         }
         Urls.Add(model);
     }
 }
示例#20
0
 /// <summary>
 /// 返回URL重写统一链接地址
 /// </summary>
 public string linkurl(string _key, params object[] _params)
 {
     Hashtable ht = new BLL.url_rewrite().GetList();
     Model.url_rewrite model = ht[_key] as Model.url_rewrite;
     if (model == null)
     {
         return "";
     }
     try
     {
         string _result = string.Empty;
         string _rewriteurl = string.Format(model.path, _params);
         switch (config.staticstatus)
         {
             case 1: //URL重写
                 _result = config.webpath + _rewriteurl;
                 break;
             case 2: //全静态
                 _rewriteurl = _rewriteurl.Substring(0, _rewriteurl.LastIndexOf(".") + 1);
                 _result = config.webpath + DTKeys.DIRECTORY_REWRITE_HTML + "/" + _rewriteurl + config.staticextension;
                 break;
             default: //不开启
                 string _originalurl = model.page;
                 if (!string.IsNullOrEmpty(model.querystring))
                 {
                     _originalurl = model.page + "?" + Regex.Replace(_rewriteurl, model.pattern, model.querystring, RegexOptions.None | RegexOptions.IgnoreCase);
                 }
                 _result = config.webpath + _originalurl;
                 break;
         }
         return _result;
     }
     catch
     {
         return "";
     }
 }
示例#21
0
        private SiteUrls()
        {
            Urls = new ArrayList();
            Paths = new NameValueCollection();

            BLL.url_rewrite bll = new BLL.url_rewrite();
            List<Model.url_rewrite> ls = bll.GetList("");
            foreach (Model.url_rewrite model in ls)
            {
                Paths.Add(model.name, model.path);
                model.page = model.page.Replace("^", "&");
                model.querystring = model.querystring.Replace("^", "&");
                Urls.Add(model);
            }
        }
        private bool DoAdd()
        {
            Model.sys_channel model = new Model.sys_channel();
            BLL.sys_channel bll = new BLL.sys_channel();
            model.name = txtName.Text.Trim();
            model.title = txtTitle.Text.Trim();
            model.model_id = int.Parse(ddlModelId.SelectedValue);
            model.sort_id = int.Parse(txtSortId.Text.Trim());
            int new_id = bll.Add(model); //保存
            if (new_id < 1)
            {
                return false;
            }
            #region 保存URL配置.开始===================================
            BLL.url_rewrite bll2 = new BLL.url_rewrite();
            bll2.Remove("channel", new_id.ToString()); //先删除
            string[] itemTypeArr = Request.Form.GetValues("item_type");
            string[] itemNameArr = Request.Form.GetValues("item_name");
            string[] itemPathArr = Request.Form.GetValues("item_path");
            string[] itemPatternArr = Request.Form.GetValues("item_pattern");
            string[] itemQuerystringArr = Request.Form.GetValues("item_querystring");
            string[] itemTempletArr = Request.Form.GetValues("item_templet");
            string[] itemPageArr = Request.Form.GetValues("item_page");
            if (itemTypeArr != null && itemNameArr != null && itemPathArr != null
            && itemPatternArr != null && itemQuerystringArr != null && itemTempletArr != null && itemPageArr != null)
            {
                if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPathArr.Length) && (itemPathArr.Length == itemPatternArr.Length)
                && (itemPatternArr.Length == itemQuerystringArr.Length) && (itemQuerystringArr.Length == itemTempletArr.Length))
                {
                    for (int i = 0; i < itemTypeArr.Length; i++)
                    {
                        bll2.Add(new Model.url_rewrite { name = itemNameArr[i].Trim(),
                        path = itemPathArr[i].Trim(),
                        pattern = itemPatternArr[i].Trim(),
                        //page = GetPageName(model.name, itemTypeArr[i].Trim()), //源页面地址
                        page = itemPageArr[i].Trim(),
                        querystring = itemQuerystringArr[i].Trim(),
                        templet = itemTempletArr[i].Trim(),
                        channel = new_id.ToString(),
                        type = itemTypeArr[i].Trim(),
                        inherit = GetInherit(model.model_id, itemTypeArr[i].Trim()) //继承的类名
                        });
                    }
                }
            }
            #endregion

            return true;
        }
示例#23
0
文件: search.cs 项目: LutherW/MTMS
 //查找匹配的URL
 private string get_url_rewrite(int channel_id, string call_index, int id)
 {
     if (channel_id == 0)
     {
         return string.Empty;
     }
     string querystring = id.ToString();
     string channel_name = new BLL.channel().GetChannelName(channel_id);
     if (string.IsNullOrEmpty(channel_name))
     {
         return string.Empty;
     }
     if (!string.IsNullOrEmpty(call_index))
     {
         querystring = call_index;
     }
     BLL.url_rewrite bll = new BLL.url_rewrite();
     Model.url_rewrite model = bll.GetInfo(channel_name, "detail");
     if (model != null)
     {
         return linkurl(model.name, querystring);
     }
     return string.Empty;
 }
示例#24
0
        private bool DoAdd()
        {
            Model.channel model = new Model.channel();
            BLL.channel   bll   = new BLL.channel();

            model.site_id = Utils.StrToInt(ddlSiteId.SelectedValue, 0);
            model.name    = txtName.Text.Trim();
            model.title   = txtTitle.Text.Trim();
            if (cbIsAlbums.Checked == true)
            {
                model.is_albums = 1;
            }
            if (cbIsAttach.Checked == true)
            {
                model.is_attach = 1;
            }
            if (cbIsSpec.Checked == true)
            {
                model.is_spec = 1;
            }
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            //扩展
            if (cbIsComment.Checked == true)
            {
                model.is_comment = 1;
            }
            if (cbIsAttr.Checked == true)
            {
                model.is_attribute = 1;
            }
            if (cbIsRecycle.Checked == true)
            {
                model.is_recycle = 1;
            }
            model.is_type = Utils.StrToInt(rblIsType.SelectedValue, 0);
            model.height  = int.Parse(txtHeight.Text.Trim(), 0);
            model.width   = int.Parse(txtWidth.Text.Trim(), 0);

            //SEO优化
            model.seo_title       = txtSeoTitle.Text.Trim();
            model.seo_keywords    = txtSeoKeywords.Text.Trim().Replace(",", ",");
            model.seo_description = txtSeoDescription.Text.Trim();

            //添加频道扩展字段
            List <Model.channel_field> ls = new List <Model.channel_field>();

            for (int i = 0; i < cblAttributeField.Items.Count; i++)
            {
                if (cblAttributeField.Items[i].Selected)
                {
                    string[] fieldIdArr = cblAttributeField.Items[i].Value.Split(','); //分解出ID值
                    ls.Add(new Model.channel_field {
                        field_id = Utils.StrToInt(fieldIdArr[1], 0)
                    });
                }
            }
            model.channel_fields = ls;

            if (bll.Add(model) < 1)
            {
                return(false);
            }

            #region 保存URL配置
            BLL.url_rewrite urlBll = new BLL.url_rewrite();
            urlBll.Remove("channel", model.name); //先删除
            string[] itemTypeArr     = Request.Form.GetValues("item_type");
            string[] itemNameArr     = Request.Form.GetValues("item_name");
            string[] itemPageArr     = Request.Form.GetValues("item_page");
            string[] itemTempletArr  = Request.Form.GetValues("item_templet");
            string[] itemPageSizeArr = Request.Form.GetValues("item_pagesize");
            string[] itemRewriteArr  = Request.Form.GetValues("item_rewrite");

            if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemPageSizeArr != null && itemRewriteArr != null)
            {
                if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length) &&
                    (itemTempletArr.Length == itemPageSizeArr.Length) && (itemPageSizeArr.Length == itemRewriteArr.Length))
                {
                    for (int i = 0; i < itemTypeArr.Length; i++)
                    {
                        Model.url_rewrite urlModel = new Model.url_rewrite();
                        urlModel.name    = itemNameArr[i].Trim();
                        urlModel.type    = itemTypeArr[i].Trim();
                        urlModel.page    = itemPageArr[i].Trim();
                        urlModel.inherit = GetInherit(urlModel.type);
                        urlModel.templet = itemTempletArr[i].Trim();
                        if (Utils.StrToInt(itemPageSizeArr[i].Trim(), 0) > 0)
                        {
                            urlModel.pagesize = itemPageSizeArr[i].Trim();
                        }
                        urlModel.channel = model.name;

                        List <Model.url_rewrite_item> itemLs = new List <Model.url_rewrite_item>();
                        string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串
                        for (int j = 0; j < urlRewriteArr.Length; j++)
                        {
                            string[] urlItemArr = urlRewriteArr[j].Split(',');
                            if (urlItemArr.Length == 3)
                            {
                                itemLs.Add(new Model.url_rewrite_item {
                                    path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2]
                                });
                            }
                        }
                        urlModel.url_rewrite_items = itemLs;
                        urlBll.Add(urlModel);
                    }
                }
            }
            #endregion

            AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加频道" + model.title); //记录日志
            return(true);
        }
 private void urlrewrite_name_validate(HttpContext context)
 {
     string new_name = MXRequest.GetString("param");
     string old_name = MXRequest.GetString("old_name");
     if (string.IsNullOrEmpty(new_name))
     {
         context.Response.Write("{ \"info\":\"名称不可为空!\", \"status\":\"n\" }");
         return;
     }
     if (new_name.ToLower() == old_name.ToLower())
     {
         context.Response.Write("{ \"info\":\"该名称可使用\", \"status\":\"y\" }");
         return;
     }
     BLL.url_rewrite bll = new BLL.url_rewrite();
     if (bll.Exists(new_name))
     {
         context.Response.Write("{ \"info\":\"该名称已被使用,请更换!\", \"status\":\"n\" }");
         return;
     }
     context.Response.Write("{ \"info\":\"该名称可使用\", \"status\":\"y\" }");
     return;
 }
示例#26
0
        private bool DoAdd()
        {
            Model.channel model = new Model.channel();
            BLL.channel bll = new BLL.channel();

            model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0);
            model.name = txtName.Text.Trim();
            model.title = txtTitle.Text.Trim();
            if (cbIsAlbums.Checked == true)
            {
                model.is_albums = 1;
            }
            if (cbIsAttach.Checked == true)
            {
                model.is_attach = 1;
            }
            if (cbIsGroupPrice.Checked == true)
            {
                model.is_group_price = 1;
            }
            model.page_size = Utils.StrToInt(txtPageSize.Text.Trim(), 10);
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            //添加频道扩展字段
            List<Model.channel_field> ls = new List<Model.channel_field>();
            for (int i = 0; i < cblAttributeField.Items.Count; i++)
            {
                if (cblAttributeField.Items[i].Selected)
                {
                    ls.Add(new Model.channel_field { field_id = Utils.StrToInt(cblAttributeField.Items[i].Value, 0) });
                }
            }
            model.channel_fields = ls;

            if (bll.Add(model) < 1)
            {
                return false;
            }

            #region 保存URL配置
            BLL.url_rewrite urlBll = new BLL.url_rewrite();
            urlBll.Remove("channel", model.name); //先删除
            string[] itemTypeArr = Request.Form.GetValues("item_type");
            string[] itemNameArr = Request.Form.GetValues("item_name");
            string[] itemPageArr = Request.Form.GetValues("item_page");
            string[] itemTempletArr = Request.Form.GetValues("item_templet");
            string[] itemRewriteArr = Request.Form.GetValues("item_rewrite");

            if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemRewriteArr != null)
            {
                if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length)
                    && (itemPageArr.Length == itemTempletArr.Length) && (itemTempletArr.Length == itemRewriteArr.Length))
                {
                    for (int i = 0; i < itemTypeArr.Length; i++)
                    {
                        Model.url_rewrite urlModel = new Model.url_rewrite();
                        urlModel.name = itemNameArr[i].Trim();
                        urlModel.type = itemTypeArr[i].Trim();
                        urlModel.page = itemPageArr[i].Trim();
                        urlModel.inherit = GetInherit(urlModel.type);
                        urlModel.templet = itemTempletArr[i].Trim();
                        urlModel.channel = model.name;

                        List<Model.url_rewrite_item> itemLs = new List<Model.url_rewrite_item>();
                        string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串
                        for (int j = 0; j < urlRewriteArr.Length; j++)
                        {
                            string[] urlItemArr = urlRewriteArr[j].Split(',');
                            if (urlItemArr.Length == 3)
                            {
                                itemLs.Add(new Model.url_rewrite_item { path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2] });
                            }
                        }
                        urlModel.url_rewrite_items = itemLs;
                        urlBll.Add(urlModel);
                    }
                }
            }
            #endregion

            AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加频道" + model.title); //记录日志
            return true;
        }
示例#27
0
        /// <summary>
        /// 返回URL重写统一链接地址
        /// </summary>
        public string linkurl(string _key, params object[] _params)
        {
            Hashtable ht = new BLL.url_rewrite().GetList();          //获得URL配置列表

            Model.url_rewrite model = ht[_key] as Model.url_rewrite; //查找指定的URL配置节点

            //如果不存在该节点则返回空字符串
            if (model == null)
            {
                return(string.Empty);
            }

            string requestDomain    = HttpContext.Current.Request.Url.Authority.ToLower(); //获得来源域名含端口号
            string requestFirstPath = GetFirstPath();                                      //获得二级目录(不含站点安装目录)
            string linkStartString  = string.Empty;                                        //链接前缀

            //检查是否与绑定的域名或者与默认频道分类的目录匹配
            if (SiteDomains.GetSiteDomains().CategoryDirs.ContainsValue(requestDomain))
            {
                linkStartString = "/";
            }

            else if (requestFirstPath == string.Empty || requestFirstPath == SiteDomains.GetSiteDomains().DefaultPath)
            {
                linkStartString = config.webpath;
            }
            else
            {
                linkStartString = config.webpath + requestFirstPath + "/";
            }
            //如果URL字典表达式不需要重写则直接返回
            if (model.url_rewrite_items.Count == 0)
            {
                //检查网站重写状态
                if (config.staticstatus > 0)
                {
                    if (_params.Length > 0)
                    {
                        return(linkStartString + GetUrlExtension(model.page, config.staticextension) + string.Format("{0}", _params));
                    }
                    else
                    {
                        return(linkStartString + GetUrlExtension(model.page, config.staticextension));
                    }
                }
                else
                {
                    if (_params.Length > 0)
                    {
                        return(linkStartString + model.page + string.Format("{0}", _params));
                    }
                    else
                    {
                        return(linkStartString + model.page);
                    }
                }
            }
            //否则检查该URL配置节点下的子节点
            foreach (Model.url_rewrite_item item in model.url_rewrite_items)
            {
                //如果参数个数匹配
                if (IsUrlMatch(item, _params))
                {
                    //检查网站重写状态
                    if (config.staticstatus > 0)
                    {
                        return(linkStartString + string.Format(GetUrlExtension(item.path, config.staticextension), _params));
                    }
                    else
                    {
                        string queryString = Regex.Replace(string.Format(item.path, _params), item.pattern, item.querystring, RegexOptions.None | RegexOptions.IgnoreCase);
                        if (queryString.Length > 0)
                        {
                            queryString = "?" + queryString;
                        }
                        return(linkStartString + model.page + queryString);
                    }
                }
            }

            return(string.Empty);
        }
示例#28
0
        private bool DoEdit(int _id)
        {
            BLL.channel bll = new BLL.channel();
            Model.channel model = bll.GetModel(_id);

            string old_name = model.name;
            model.site_id = Utils.StrToInt(ddlSiteId.SelectedValue, 0);
            model.name = txtName.Text.Trim();
            model.title = txtTitle.Text.Trim();
            model.is_albums = 0;
            model.is_attach = 0;
            model.is_spec = 0;
            if (cbIsAlbums.Checked == true)
            {
                model.is_albums = 1;
            }
            if (cbIsAttach.Checked == true)
            {
                model.is_attach = 1;
            }
            if (cbIsSpec.Checked == true)
            {
                model.is_spec = 1;
            }
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            //添加频道扩展字段
            List<Model.channel_field> ls = new List<Model.channel_field>();
            for (int i = 0; i < cblAttributeField.Items.Count; i++)
            {
                if (cblAttributeField.Items[i].Selected)
                {
                    string[] fieldIdArr = cblAttributeField.Items[i].Value.Split(','); //分解出ID值
                    ls.Add(new Model.channel_field { channel_id = model.id, field_id = Utils.StrToInt(fieldIdArr[1], 0) });
                }
            }
            model.channel_fields = ls;

            if (!bll.Update(model))
            {
                return false;
            }

            #region 保存URL配置
            BLL.url_rewrite urlBll = new BLL.url_rewrite();
            urlBll.Remove("channel", old_name); //先删除旧的
            string[] itemTypeArr = Request.Form.GetValues("item_type");
            string[] itemNameArr = Request.Form.GetValues("item_name");
            string[] itemPageArr = Request.Form.GetValues("item_page");
            string[] itemTempletArr = Request.Form.GetValues("item_templet");
            string[] itemPageSizeArr = Request.Form.GetValues("item_pagesize");
            string[] itemRewriteArr = Request.Form.GetValues("item_rewrite");

            if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemPageSizeArr != null && itemRewriteArr != null)
            {
                if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length)
                    && (itemTempletArr.Length == itemPageSizeArr.Length) && (itemPageSizeArr.Length == itemRewriteArr.Length))
                {
                    for (int i = 0; i < itemTypeArr.Length; i++)
                    {
                        Model.url_rewrite urlModel = new Model.url_rewrite();
                        urlModel.name = itemNameArr[i].Trim();
                        urlModel.type = itemTypeArr[i].Trim();
                        urlModel.page = itemPageArr[i].Trim();
                        urlModel.inherit = GetInherit(urlModel.type);
                        urlModel.templet = itemTempletArr[i].Trim();
                        if (Utils.StrToInt(itemPageSizeArr[i].Trim(), 0) > 0)
                        {
                            urlModel.pagesize = itemPageSizeArr[i].Trim();
                        }
                        urlModel.channel = model.name;

                        List<Model.url_rewrite_item> itemLs = new List<Model.url_rewrite_item>();
                        string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串
                        for (int j = 0; j < urlRewriteArr.Length; j++)
                        {
                            string[] urlItemArr = urlRewriteArr[j].Split(',');
                            if (urlItemArr.Length == 3)
                            {
                                itemLs.Add(new Model.url_rewrite_item { path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2] });
                            }
                        }
                        urlModel.url_rewrite_items = itemLs;
                        urlBll.Add(urlModel);
                    }
                }
            }
            #endregion

            AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改频道" + model.title); //记录日志
            return true;
        }
示例#29
0
        private bool DoAdd()
        {
            Model.site_channel model = new Model.site_channel();
            BLL.site_channel   bll   = new BLL.site_channel();

            model.site_id = Utils.StrToInt(ddlSiteId.SelectedValue, 0);
            model.name    = txtName.Text.Trim();
            model.title   = txtTitle.Text.Trim();
            if (cbIsLock.Checked == false)
            {
                model.is_lock = 1;
            }
            if (cbIsComment.Checked == true)
            {
                model.is_comment = 1;
            }
            if (cbIsAlbums.Checked == true)
            {
                model.is_albums = 1;
            }
            if (cbIsAttach.Checked == true)
            {
                model.is_attach = 1;
            }
            if (cbIsSpec.Checked == true)
            {
                model.is_spec = 1;
            }
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            //添加频道扩展字段
            List <Model.site_channel_field> ls = new List <Model.site_channel_field>();

            for (int i = 0; i < cblAttributeField.Items.Count; i++)
            {
                if (cblAttributeField.Items[i].Selected)
                {
                    string[] fieldIdArr = cblAttributeField.Items[i].Value.Split(','); //分解出ID值
                    ls.Add(new Model.site_channel_field {
                        field_id = Utils.StrToInt(fieldIdArr[1], 0)
                    });
                }
            }
            model.channel_fields = ls;

            if (bll.Add(model) < 1)
            {
                return(false);
            }

            #region 保存URL配置
            BLL.url_rewrite urlBll = new BLL.url_rewrite();
            urlBll.Remove("channel", model.name); //先删除
            string[] itemTypeArr     = Request.Form.GetValues("item_type");
            string[] itemNameArr     = Request.Form.GetValues("item_name");
            string[] itemPageArr     = Request.Form.GetValues("item_page");
            string[] itemTempletArr  = Request.Form.GetValues("item_templet");
            string[] itemPageSizeArr = Request.Form.GetValues("item_pagesize");
            string[] itemRewriteArr  = Request.Form.GetValues("item_rewrite");

            if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemPageSizeArr != null && itemRewriteArr != null)
            {
                if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length) &&
                    (itemTempletArr.Length == itemPageSizeArr.Length) && (itemPageSizeArr.Length == itemRewriteArr.Length))
                {
                    for (int i = 0; i < itemTypeArr.Length; i++)
                    {
                        Model.url_rewrite urlModel = new Model.url_rewrite();
                        urlModel.name    = itemNameArr[i].Trim();
                        urlModel.type    = itemTypeArr[i].Trim();
                        urlModel.page    = itemPageArr[i].Trim();
                        urlModel.inherit = GetInherit(urlModel.type);
                        urlModel.templet = itemTempletArr[i].Trim();
                        if (Utils.StrToInt(itemPageSizeArr[i].Trim(), 0) > 0)
                        {
                            urlModel.pagesize = itemPageSizeArr[i].Trim();
                        }
                        urlModel.channel = model.name;

                        List <Model.url_rewrite_item> itemLs = new List <Model.url_rewrite_item>();
                        string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串
                        for (int j = 0; j < urlRewriteArr.Length; j++)
                        {
                            string[] urlItemArr = urlRewriteArr[j].Split(',');
                            if (urlItemArr.Length == 3)
                            {
                                itemLs.Add(new Model.url_rewrite_item {
                                    path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2]
                                });
                            }
                        }
                        urlModel.url_rewrite_items = itemLs;
                        urlBll.Add(urlModel);
                    }
                }
            }
            else
            {
                #region 添加默认URl配置
                //列表url
                Model.url_rewrite urlModelList = new Model.url_rewrite();
                urlModelList.name     = model.name;
                urlModelList.type     = "list";
                urlModelList.page     = model.name + ".aspx";
                urlModelList.inherit  = GetInherit(urlModelList.type);
                urlModelList.templet  = model.name + ".html";
                urlModelList.pagesize = "20";
                urlModelList.channel  = model.name;
                List <Model.url_rewrite_item> listItems = new List <Model.url_rewrite_item>
                {
                    new Model.url_rewrite_item()
                    {
                        path    = model.name + ".aspx",
                        pattern = model.name + ".aspx"
                    },
                    new Model.url_rewrite_item()
                    {
                        path        = model.name + "/{0}.aspx",
                        pattern     = model.name + "/(\\d+).aspx",
                        querystring = "category_id=$1"
                    },
                    new Model.url_rewrite_item()
                    {
                        path        = model.name + "/{0}/{1}.aspx",
                        pattern     = model.name + "/(\\d+)/(\\w+).aspx",
                        querystring = "category_id=$1^page=$2"
                    }
                };
                urlModelList.url_rewrite_items = listItems;
                urlBll.Add(urlModelList);
                //详情页url
                Model.url_rewrite urlModelShow = new Model.url_rewrite();
                urlModelShow.name    = model.name + "_show";
                urlModelShow.type    = "detail";
                urlModelShow.page    = model.name + "_show.aspx";
                urlModelShow.inherit = GetInherit(urlModelShow.type);
                urlModelShow.templet = model.name + "_show.html";
                urlModelShow.channel = model.name;
                List <Model.url_rewrite_item> showItems = new List <Model.url_rewrite_item>
                {
                    new Model.url_rewrite_item()
                    {
                        path        = model.name + "/show-{0}.aspx",
                        pattern     = model.name + "/show-(\\d+).aspx",
                        querystring = "id=$1"
                    }
                };
                urlModelShow.url_rewrite_items = showItems;
                urlBll.Add(urlModelShow);
                #endregion
            }
            #endregion

            AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加频道" + model.title); //记录日志
            return(true);
        }
示例#30
0
 private void sys_urlrewrite_validate(HttpContext context)
 {
     string rewritekey = DTRequest.GetFormString("rewritekey");
     string oldkey = DTRequest.GetFormString("oldkey");
     if (string.IsNullOrEmpty(rewritekey))
     {
         context.Response.Write("false1");
         return;
     }
     //检查是否修改操作
     if (rewritekey.ToLower() == oldkey.ToLower())
     {
         context.Response.Write("true");
         return;
     }
     //检查站点URL配置文件节点是否重复
     List<Model.url_rewrite> ls = new BLL.url_rewrite().GetList("");
     foreach (Model.url_rewrite model in ls)
     {
         if (model.name.ToLower() == rewritekey.ToLower())
         {
             context.Response.Write("false2");
             return;
         }
     }
     context.Response.Write("true");
     return;
 }
示例#31
0
        private bool DoEdit(int _id)
        {
            BLL.site_channel   bll   = new BLL.site_channel();
            Model.site_channel model = bll.GetModel(_id);

            string old_name = model.name;

            model.site_id    = Utils.StrToInt(ddlSiteId.SelectedValue, 0);
            model.name       = txtName.Text.Trim();
            model.title      = txtTitle.Text.Trim();
            model.is_lock    = 0;
            model.is_comment = 0;
            model.is_albums  = 0;
            model.is_attach  = 0;
            model.is_spec    = 0;
            if (cbIsLock.Checked == false)
            {
                model.is_lock = 1;
            }
            if (cbIsComment.Checked == true)
            {
                model.is_comment = 1;
            }
            if (cbIsAlbums.Checked == true)
            {
                model.is_albums = 1;
            }
            if (cbIsAttach.Checked == true)
            {
                model.is_attach = 1;
            }
            if (cbIsSpec.Checked == true)
            {
                model.is_spec = 1;
            }
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            //添加频道扩展字段
            List <Model.site_channel_field> ls = new List <Model.site_channel_field>();

            for (int i = 0; i < cblAttributeField.Items.Count; i++)
            {
                if (cblAttributeField.Items[i].Selected)
                {
                    string[] fieldIdArr = cblAttributeField.Items[i].Value.Split(','); //分解出ID值
                    ls.Add(new Model.site_channel_field {
                        channel_id = model.id, field_id = Utils.StrToInt(fieldIdArr[1], 0)
                    });
                }
            }
            model.channel_fields = ls;

            if (!bll.Update(model))
            {
                return(false);
            }

            #region 保存URL配置
            BLL.url_rewrite urlBll = new BLL.url_rewrite();
            urlBll.Remove("channel", old_name); //先删除旧的
            string[] itemTypeArr     = Request.Form.GetValues("item_type");
            string[] itemNameArr     = Request.Form.GetValues("item_name");
            string[] itemPageArr     = Request.Form.GetValues("item_page");
            string[] itemTempletArr  = Request.Form.GetValues("item_templet");
            string[] itemPageSizeArr = Request.Form.GetValues("item_pagesize");
            string[] itemRewriteArr  = Request.Form.GetValues("item_rewrite");

            if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemPageSizeArr != null && itemRewriteArr != null)
            {
                if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length) &&
                    (itemTempletArr.Length == itemPageSizeArr.Length) && (itemPageSizeArr.Length == itemRewriteArr.Length))
                {
                    for (int i = 0; i < itemTypeArr.Length; i++)
                    {
                        Model.url_rewrite urlModel = new Model.url_rewrite();
                        urlModel.name    = itemNameArr[i].Trim();
                        urlModel.type    = itemTypeArr[i].Trim();
                        urlModel.page    = itemPageArr[i].Trim();
                        urlModel.inherit = GetInherit(urlModel.type);
                        urlModel.templet = itemTempletArr[i].Trim();
                        if (Utils.StrToInt(itemPageSizeArr[i].Trim(), 0) > 0)
                        {
                            urlModel.pagesize = itemPageSizeArr[i].Trim();
                        }
                        urlModel.channel = model.name;

                        List <Model.url_rewrite_item> itemLs = new List <Model.url_rewrite_item>();
                        string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串
                        for (int j = 0; j < urlRewriteArr.Length; j++)
                        {
                            string[] urlItemArr = urlRewriteArr[j].Split(',');
                            if (urlItemArr.Length == 3)
                            {
                                itemLs.Add(new Model.url_rewrite_item {
                                    path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2]
                                });
                            }
                        }
                        urlModel.url_rewrite_items = itemLs;
                        urlBll.Add(urlModel);
                    }
                }
            }
            #endregion

            AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改频道" + model.title); //记录日志
            return(true);
        }
示例#32
0
        /// <summary>
        /// 返回URL重写统一链接地址
        /// </summary>
        public string linkurl(string _key, params object[] _params)
        {
            Hashtable ht = new BLL.url_rewrite().GetList(); //获得URL配置列表
            Model.url_rewrite model = ht[_key] as Model.url_rewrite; //查找指定的URL配置节点

            //如果不存在该节点则返回空字符串
            if (model == null)
            {
                return string.Empty;
            }

            string requestDomain = HttpContext.Current.Request.Url.Authority.ToLower(); //获得来源域名含端口号
            string requestPath = HttpContext.Current.Request.RawUrl.ToLower(); //当前的URL地址
            string linkStartString = GetLinkStartString(requestPath, requestDomain); //链接前缀

            //如果URL字典表达式不需要重写则直接返回
            if (model.url_rewrite_items.Count == 0)
            {
                //检查网站重写状态
                if (config.staticstatus > 0)
                {
                    if (_params.Length > 0)
                    {
                        return linkStartString + GetUrlExtension(model.page, config.staticextension) + string.Format("{0}", _params);
                    }
                    else
                    {
                        return linkStartString + GetUrlExtension(model.page, config.staticextension);
                    }
                }
                else
                {
                    if (_params.Length > 0)
                    {
                        return linkStartString + model.page + string.Format("{0}", _params);
                    }
                    else
                    {
                        return linkStartString + model.page;
                    }
                }
            }
            //否则检查该URL配置节点下的子节点
            foreach (Model.url_rewrite_item item in model.url_rewrite_items)
            {
                //如果参数个数匹配
                if (IsUrlMatch(item, _params))
                {
                    //检查网站重写状态
                    if (config.staticstatus > 0)
                    {
                        return linkStartString + string.Format(GetUrlExtension(item.path, config.staticextension), _params);
                    }
                    else
                    {
                        string queryString = Regex.Replace(string.Format(item.path, _params), item.pattern, item.querystring, RegexOptions.None | RegexOptions.IgnoreCase);
                        if (queryString.Length > 0)
                        {
                            queryString = "?" + queryString;
                        }
                        return linkStartString + model.page + queryString;
                    }
                }
            }
               
            return string.Empty;
        }