惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
博客园 - 【当耐特】
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
D
Docker
GbyAI
GbyAI
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
The Cloudflare Blog
雷峰网
雷峰网
A
About on SuperTechFans
小众软件
小众软件
博客园 - Franky
博客园 - 聂微东
F
Full Disclosure
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
MongoDB | Blog
MongoDB | Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
V2EX
Engineering at Meta
Engineering at Meta
宝玉的分享
宝玉的分享
aimingoo的专栏
aimingoo的专栏
量子位
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
罗磊的独立博客
Martin Fowler
Martin Fowler
D
DataBreaches.Net
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Secure Thoughts
Project Zero
Project Zero
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
S
Schneier on Security
Blog — PlanetScale
Blog — PlanetScale
The Hacker News
The Hacker News
Spread Privacy
Spread Privacy
Security Latest
Security Latest
NISL@THU
NISL@THU
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CXSECURITY Database RSS Feed - CXSecurity.com
J
Java Code Geeks

博客园 - Ray Lynn

使用 flex air 读写文件 - Ray Lynn Google Chrome 源码下载 什么是SAAS? QQ盗号木马原理 WindowsSockets 错误码 js操作cookies类 使用 Microsoft SOAP Toolkit 2.0 建立安全 Web 服务 历史上最强的代码 饭否,唧歪们MSN、QQ、GTalk机器人实现原理及代码 这是比月读还强的幻术!! - Ray Lynn - 博客园 伪静态网页的实现 ACCESS 创建表及索引方式 VB6 判断网络是否正常类 眼保健操 面向服务的面向业务基础 VB6编程中如何获取硬盘分区信息 原味香菇片蒸鸡腿 定制特性学习笔记 [转]C#中的定制特性(Attributes)
.net 中的伪静态方式. 来自 Discuz!NT
Ray Lynn · 2007-08-09 · via 博客园 - Ray Lynn

    <httpModules>
        
<add type="Discuz.Forum.HttpModule, Discuz.Forum" name="HttpModule" />
    
</httpModules>

<?xml version="1.0" encoding="utf-8" ?> 
<urls>
     
<rewrite name="showforum"
          path
="/showforum-{0}-{1}.aspx"
          pattern 
= "/showforum-(\d+)(-(\d+))?.aspx"
          page
="/showforum.aspx"
          querystring
="forumid=$1^page=$3" />
    
<rewrite name="showtopic"
          path
="/showtopic-{0}-{1}.aspx"
          pattern 
= "/showtopic-(\d+)(-(\d+))?.aspx"
          page
="/showtopic.aspx"
          querystring
="topicid=$1^page=$3" />
    
<rewrite name="userinfo"
          path
="/userinfo-{0}.aspx"
          pattern 
= "/userinfo-(\d+)*.aspx"
          page
="/userinfo.aspx"
          querystring
="userid=$1" />
     
<rewrite name="rss"
          path
="/rss-{0}.aspx"
          pattern 
= "/rss(-(\d+))?.aspx"
          page
="/rss.aspx"
          querystring
="forumid=$2" />
</urls>

/*
 * Discuz!NT Version: 1.0
 * Created on 2007-3-30
 *
 * Web: 
http://www.discuznt.com
 * Copyright (C) 2001 - 2007 Comsenz Technology Inc., All Rights Reserved.
 * This is NOT a freeware, use is subject to license terms.
 *
 
*/



using System;
using System.Diagnostics;
using System.Threading;
using System.Web;
using System.Xml;
using System.Text.RegularExpressions;
using Discuz.Common;

namespace Discuz.Forum
{
    
/// <summary>
    
/// HttpModule 的摘要说明。
    
/// </summary>

    public class HttpModule : System.Web.IHttpModule
    
{
        
//public readonly static Mutex m=new Mutex();

        
/// <summary>
        
/// 实现接口的Init方法
        
/// </summary>
        
/// <param name="context"></param>

        public void Init(HttpApplication context)
        
{
            OnlineUserFactory.ResetOnlineList();
            context.BeginRequest 
+= new EventHandler(ReUrl_BeginRequest);

        }


        
public void Application_OnError(Object sender , EventArgs e)
        
{
            HttpApplication application 
= (HttpApplication)sender; 
            HttpContext context 
= application.Context; 
            
//if (context.Server.GetLastError().GetBaseException() is MyException)
            {
                
//MyException ex = (MyException) context.Server.GetLastError().GetBaseException();
                context.Response.Write("<html><body style=\"font-size:14px;\">");
                context.Response.Write(
"Discuz!NT Error:<br />");
                context.Response.Write(
"<textarea name=\"errormessage\" style=\"width:80%; height:200px; word-break:break-all\">");
                context.Response.Write(System.Web.HttpUtility.HtmlEncode(context.Server.GetLastError().ToString()));
                context.Response.Write(
"</textarea>");
                context.Response.Write(
"</body></html>");
                context.Response.End();
            }
 

        }


        
/// <summary>
        
/// 实现接口的Dispose方法
        
/// </summary>

        public void Dispose()
        
{
        }


        
/// <summary>
        
/// 重写Url
        
/// </summary>
        
/// <param name="sender">事件的源</param>
        
/// <param name="e">包含事件数据的 EventArgs</param>

        private void ReUrl_BeginRequest(object sender, EventArgs e)
        
{
            BaseConfigInfo config 
= Providers.BaseConfigProvider.Instance();
            
if (config == null)
                
return;
            HttpContext context 
= ((HttpApplication)sender).Context;
            
string forumPath = BaseConfigFactory.GetForumPath.ToLower();

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

            
if (requestPath.StartsWith(forumPath))
            
{
                
if (requestPath.Substring(forumPath.Length).IndexOf("/"== -1)
                
{
                    
// 当前样式id
                    string strTemplateid = ConfigFactory.GetDefaultTemplateID().ToString();
                    
//string ttt = Utils.GetCookie("dnttemplateid");
                    if (Utils.InArray(Utils.GetCookie("dnttemplateid"), TemplateFactory.GetValidTemplateIDList()))
                    
{
                        strTemplateid 
= Utils.GetCookie("dnttemplateid");
                    }


                    
foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls)
                    
{
                        
if (Regex.IsMatch(requestPath, url.Pattern, RegexOptions.Compiled|RegexOptions.IgnoreCase))
                        
{
                            
string newUrl = Regex.Replace(requestPath.Substring(context.Request.Path.LastIndexOf("/")), url.Pattern, url.QueryString, RegexOptions.Compiled|RegexOptions.IgnoreCase);
                    
                            context.RewritePath(forumPath 
+ "aspx/" + strTemplateid + url.Page, string.Empty, newUrl);

                            
return;
                        }

                    }

                    context.RewritePath(forumPath 
+ "aspx/" + strTemplateid + requestPath.Substring(context.Request.Path.LastIndexOf("/")));
                }

                
                
else if (requestPath.StartsWith(forumPath + "archiver/"))
                
{
                    
string path = requestPath.Substring(forumPath.Length + 8);
                    
foreach(SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls)
                    
{
                        
if (Regex.IsMatch(path, url.Pattern, RegexOptions.Compiled|RegexOptions.IgnoreCase))
                        
{
                            
string newUrl = Regex.Replace(path, url.Pattern, url.QueryString, RegexOptions.Compiled|RegexOptions.IgnoreCase);
                    
                            context.RewritePath(forumPath 
+ "archiver" + url.Page, string.Empty, newUrl);
                            
return;
                        }

                    }

                    
return;
                }

                
else if (requestPath.StartsWith(forumPath + "tools/"))
                
{
                    
string path = requestPath.Substring(forumPath.Length + 5);
                    
foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls)
                    
{
                        
if (Regex.IsMatch(path, url.Pattern, RegexOptions.Compiled|RegexOptions.IgnoreCase))
                        
{
                            
string newUrl = Regex.Replace(path, url.Pattern, url.QueryString, RegexOptions.Compiled|RegexOptions.IgnoreCase);
                    
                            context.RewritePath(forumPath 
+ "tools" + url.Page, string.Empty, newUrl);
                            
return;
                        }

                    }

                    
return;
                }


            }


        
        }


    }




    
//////////////////////////////////////////////////////////////////////
    public class SiteUrls
    
{
        
内部属性和方法

        
public static SiteUrls GetSiteUrls()
        
{
            
if (instance == null)
            
{
                
lock (lockHelper)
                
{
                    
if (instance == null)
                    
{
                        instance 
= new SiteUrls();
                    }

                }

            }

            
return instance;

        }


        
public static void SetInstance(SiteUrls anInstance)
        
{
            
if (anInstance != null)
                instance 
= anInstance;
        }


        
public static void SetInstance()
        
{
            SetInstance(
new SiteUrls());
        }


        
/// <summary>
        
/// 输出URL示例
        
/// </summary>
        
/// <param name="id"></param>
        
/// <returns></returns>

        public string Show(int id)
        
{
            
return string.Format(Paths["Show"], id);
        }



        
public class URLRewrite
        
{
            
成员变量 

            
构造函数
        }


    }








}