An alternative to UBB.threads
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FLocal/IISMainHandler/handlers/response/LegacyPHPHandler.cs

43 lines
1.4 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FLocal.Core;
using FLocal.Common;
using FLocal.Common.dataobjects;
namespace FLocal.IISHandler.handlers.response {
class LegacyPHPHandler : RedirectGetHandler {
protected override string getRedirectUrl(WebContext context) {
string[] scriptParts = context.requestParts[0].Split('.');
if(scriptParts.Length != 2) {
//throw new FLocalException("wrong url");
throw new WrongUrlException();
}
if(scriptParts[1].ToLower() != "php") {
//throw new FLocalException("wrong url");
throw new WrongUrlException();
}
switch(scriptParts[0].ToLower()) {
case "showflat":
case "ashowflat":
Post post = Post.LoadById(int.Parse(context.httprequest.QueryString["Number"]));
return "/Thread/" + post.thread.id.ToString() + "/p" + post.id.ToString();
case "showthreaded":
case "ashowthreaded":
return "/Post/" + int.Parse(context.httprequest.QueryString["Number"]).ToString() + "/";
case "postlist":
return "/Board/" + Board.LoadByLegacyName(context.httprequest.QueryString["Board"]).id.ToString() + "/";
case "showprofile":
return "/User/" + User.LoadByName(context.httprequest.QueryString["User"]).id.ToString() + "/";
default:
//throw new NotImplementedException("unknown script " + scriptParts[0]);
throw new WrongUrlException();
}
}
}
}