// 如果缓存中存在,则直接返回 void publisher_Begin_ProcessMvc(object sender, MvcEventArgs e) { String cPath = e.ctx.url.Path; if (cPath.ToLower().IndexOf("/layouts/topnav/nav") >= 0) { if (e.ctx.web.UserIsLogin == false) { OnlineManager.Refresh(e.ctx); OnlineStats o = OnlineStats.Instance; String onlineInfo = "{\"count\":" + o.Count + ",\"member\":" + o.MemberCount + ",\"guest\":" + o.GuestCount + ",\"max\":" + o.MaxCount + ",\"maxTime\":\"" + o.MaxTime.ToShortDateString() + "\"}"; String isSite = cPath.IndexOf("/Layouts/") == 0 ? "true" : "false"; String connects = getConnectLinks(); //String json = "{\"viewer\":{\"obj\" :{\"Id\":0,\"Name\":\"guest\",\"Url\":\"\"},\"Id\":0,\"IsLogin\":false,\"IsAdministrator\":false,\"HasPic\":false}, \"owner\":{\"IsSite\":" + isSite + ", \"LoginValidImg\":" + config.Instance.Site.LoginNeedImgValidation.ToString().ToLower() + "},\"navInfo\":{\"topNavDisplay\":" + config.Instance.Site.TopNavDisplay + "}, \"online\":" + onlineInfo + "}"; String json = "{\"viewer\":{\"obj\" :{\"Id\":0,\"Name\":\"guest\",\"Url\":\"\"},\"Id\":0,\"IsLogin\":false,\"IsAdministrator\":false,\"HasPic\":false}, \"owner\":{\"IsSite\":" + isSite + ", \"LoginValidImg\":" + config.Instance.Site.LoginNeedImgValidation.ToString().ToLower() + "},\"navInfo\":{\"topNavDisplay\":" + config.Instance.Site.TopNavDisplay + "}, \"online\":" + onlineInfo + ", \"connects\":" + connects + "}"; e.ctx.RenderJson(json); e.ctx.utils.end(); e.ctx.utils.skipRender(); return; } } }
void publisher_End_ProcessAction(object sender, MvcEventArgs e) { MvcContext ctx = e.ctx; if (ctx.HttpMethod.Equals("GET")) { return; } if (!(ctx.owner.obj is Site)) { return; } List <ICacheFilter> dbs = CacheFilterDB.Instance.Renews; foreach (ICacheFilter cr in dbs) { if (actionSame(cr, ctx)) { cr.Update(ctx); break; } } }
void publisher_Begin_Render(object sender, MvcEventArgs e) { String output = e.ctx.utils.getCurrentOutputString(); if (e.ctx.url.Path.IndexOf("/Admin/") < 0) { string[] arrWords = config.Instance.Site.BadWords; foreach (String w in arrWords) { output = output.Replace(w, config.Instance.Site.BadWordsReplacement); } } //output = strUtil.ResetScript( output ); if (ch.shouldCache(e.ctx)) { ch.AddCache(e.ctx.url.PathAndQuery, output); } //output = output.Replace( "#{elapseTime}", getTimeStr() ); output = output.Replace("</body>", getTimeJs() + "</body>"); e.ctx.utils.setCurrentOutputString(output); }
void publisher_Begin_Render(object sender, MvcEventArgs e) { // 获取即将输出的内容 string output = e.ctx.utils.getCurrentOutputString(); // 修改输出的内容 output = output.Replace("#{pageElapsedMilliseconds}", WebStopwatch.Stop().ElapsedMilliseconds.ToString("0.0000")); // 将修改后的内容放回上下文 e.ctx.utils.setCurrentOutputString(output); }
// 如果缓存中存在,则直接返回 void publisher_Begin_ProcessMvc(object sender, MvcEventArgs e) { String cPath = e.ctx.url.Path; if (cPath.IndexOf("/Layouts/TopNav/Nav") >= 0) { if (e.ctx.web.UserIsLogin == false) { OnlineManager.Refresh(e.ctx); OnlineStats o = OnlineStats.Instance; String onlineInfo = "{\"count\":" + o.Count + ",\"member\":" + o.MemberCount + ",\"guest\":" + o.GuestCount + ",\"max\":" + o.MaxCount + ",\"maxTime\":\"" + o.MaxTime.ToShortDateString() + "\"}"; String isSite = cPath.IndexOf("/Layouts/") == 0 ? "true" : "false"; String json = "{\"viewer\":{\"obj\" :{\"Id\":0,\"Name\":\"guest\",\"Url\":\"\"},\"Id\":0,\"IsLogin\":false,\"IsAdministrator\":false,\"HasPic\":false}, \"owner\":{\"IsSite\":" + isSite + ", \"LoginValidImg\":" + config.Instance.Site.LoginNeedImgValidation.ToString().ToLower() + "},\"navInfo\":{\"topNavDisplay\":" + config.Instance.Site.TopNavDisplay + "}, \"online\":" + onlineInfo + "}"; e.ctx.RenderJson(json); e.ctx.utils.end(); e.ctx.utils.skipRender(); return; } } //------------------------------------------------------ if (ch.shouldCache(e.ctx) == false) { return; } String pageContent = ch.ReadCache(e.ctx.url.PathAndQuery, e.ctx); if (pageContent == null) { return; } //pageContent = pageContent.Replace( "#{elapseTime}", getTimeStr() ); pageContent += getTimeJs(); e.ctx.web.ResponseWrite(pageContent.ToString()); e.ctx.utils.end(); e.ctx.utils.skipRender(); logger.Info("----------------------------------cacheEnd------------------------------------"); LogManager.Flush(); }
void publisher_Begin_ParseRoute(object sender, MvcEventArgs e) { if (config.Instance.Site.IsInstall) { return; } MvcContext ctx = e.ctx; if (ctx.url.Path.IndexOf("/Installer/") < 0) { String installerUrl = "/Installer/Index" + MvcConfig.Instance.UrlExt; ctx.setUrl(strUtil.Join(ctx.url.SiteAndAppPath, installerUrl)); } }
void publisher_Begin_Render(object sender, MvcEventArgs e) { String output = e.ctx.utils.getCurrentOutputString(); if (e.ctx.url.Path.IndexOf("/Admin/") < 0) { string[] arrWords = config.Instance.Site.BadWords; foreach (String w in arrWords) { output = output.Replace(w, config.Instance.Site.BadWordsReplacement); } } // 加上页面执行时间 output = output.Replace("</body>", getTimeJs() + "</body>"); e.ctx.utils.setCurrentOutputString(output); }
void publisher_Begin_InitContext(object sender, MvcEventArgs e) { if (config.Instance.Site.IsInstall) { return; } MvcContext ctx = e.ctx; if (ctx.utils.isSkipCurrentProcessor()) { return; } ContextInitDefault init = new ContextInitDefault(); init.InitController(ctx); ctx.utils.skipCurrentProcessor(true); // 跳过下面正常的init }
void publisher_Begin_ParseRoute(object sender, MvcEventArgs e) { if (MvcConfig.Instance.IsDomainMap == false) { return; } if (SystemInfo.HostIsIp) { return; } if (SystemInfo.HostIsLocalhost) { return; } logger.Info("===============subdomain publisher_Begin_ParseRoute=============="); MvcContext ctx = e.ctx; String host = ctx.url.Host; if (host == null) { return; } String[] arrItem = host.Split('.'); if (arrItem.Length != 3) { return; } if (strUtil.EqualsIgnoreCase(arrItem[0], "www")) { return; } String newHostAndPath = getNewHostPath(ctx, arrItem); logger.Info("newHost_final=" + newHostAndPath); // 重设当前 url e.ctx.setUrl(newHostAndPath); }