行 1: #pragma checksum "D:\EPR2008\global.asax" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "43BAFBFFE4A3D16C233CA83193509977"
行 2: //------------------------------------------------------------------------------
行 3: // <auto-generated>
行 4: // 此代码由工具生成。
行 5: // 运行时版本:2.0.50727.3662
行 6: //
行 7: // 对此文件的更改可能会导致不正确的行为,并且如果
行 8: // 重新生成代码,这些更改将会丢失。
行 9: // </auto-generated>
行 10: //------------------------------------------------------------------------------
行 11:
行 12: namespace ASP {
行 13:
行 14: #line 314 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 15: using System.Web.Profile;
行 16:
行 17: #line default
行 18: #line hidden
行 19:
行 20: #line 309 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 21: using System.Text.RegularExpressions;
行 22:
行 23: #line default
行 24: #line hidden
行 25:
行 26: #line 311 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 27: using System.Web.Caching;
行 28:
行 29: #line default
行 30: #line hidden
行 31:
行 32: #line 307 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 33: using System.Configuration;
行 34:
行 35: #line default
行 36: #line hidden
行 37:
行 38: #line 306 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 39: using System.Collections.Specialized;
行 40:
行 41: #line default
行 42: #line hidden
行 43:
行 44: #line 318 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 45: using System.Web.UI.HtmlControls;
行 46:
行 47: #line default
行 48: #line hidden
行 49:
行 50: #line 316 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 51: using System.Web.UI.WebControls;
行 52:
行 53: #line default
行 54: #line hidden
行 55:
行 56: #line 305 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 57: using System.Collections;
行 58:
行 59: #line default
行 60: #line hidden
行 61:
行 62: #line 315 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 63: using System.Web.UI;
行 64:
行 65: #line default
行 66: #line hidden
行 67:
行 68: #line 317 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 69: using System.Web.UI.WebControls.WebParts;
行 70:
行 71: #line default
行 72: #line hidden
行 73:
行 74: #line 304 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 75: using System;
行 76:
行 77: #line default
行 78: #line hidden
行 79:
行 80: #line 313 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 81: using System.Web.Security;
行 82:
行 83: #line default
行 84: #line hidden
行 85:
行 86: #line 310 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 87: using System.Web;
行 88:
行 89: #line default
行 90: #line hidden
行 91:
行 92: #line 312 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 93: using System.Web.SessionState;
行 94:
行 95: #line default
行 96: #line hidden
行 97:
行 98: #line 308 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config"
行 99: using System.Text;
行 100:
行 101: #line default
行 102: #line hidden
行 103:
行 104:
行 105: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
行 106: public class global_asax : global::System.Web.HttpApplication {
行 107:
行 108: private static bool @__initialized;
行 109:
行 110:
行 111: #line 3 "D:\EPR2008\global.asax"
行 112:
行 113:
行 114: void Application_Start(object sender, EventArgs e)
行 115: {
行 116: // 在应用程序启动时运行的代码
行 117: EPR.Common.Service.ServiceManager.init();
行 118: //Appraise.Implement.CCal.Init();
行 119: C10.BLL.Manager.GlobalManager gm = C10.BLL.Manager.GlobalManager.GetInstance();
行 120: EPR.Logon.eprCommon eprCommon = new EPR.Logon.eprCommon();
行 121: System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["EPRConnectionString_log"].ConnectionString.ToString().Trim());
行 122:
行 123: object obj = eprCommon.ExecuteSelectSQL("select count from t_ps01_counter", conn);
行 124: if (obj != null)
行 125: {
行 126: Application["total"] = (int)obj;
行 127: Application["total0"] = (int)obj;//记录底数
行 128: }
行 129:
行 130: string IISlog_file = System.Web.HttpContext.Current.Server.MapPath("~/log/iisLog.txt");
行 131: if (!System.IO.File.Exists(IISlog_file))
行 132: {
行 133: System.IO.FileStream Fs = System.IO.File.Create(IISlog_file);
行 134: Fs.Close();
行 135: }
行 136: System.IO.StreamWriter sw = new System.IO.StreamWriter(IISlog_file, true);
行 137: sw.WriteLine(System.DateTime.Now.ToString() + " IIS启动");
行 138: sw.Close();
行 139:
行 140: Application["online"] = 0;
行 141: // Application["total"] = 0;
行 142: eprCommon.ExecuteSQL("update t_ps01_message set ifshow=0 where ifshow=1", conn);
行 143:
行 144: //清除R07dbf文件导出后的垃圾文件
行 145: string path = "";
行 146: path = Server.MapPath("~/EPR/R07/export/temp");
行 147: if (System.IO.Directory.Exists(path))
行 148: System.IO.Directory.Delete(path, true);
行 149: System.IO.Directory.CreateDirectory(path);
行 150: }
行 151:
行 152: void Application_End(object sender, EventArgs e)
行 153: {
行 154: // 在应用程序关闭时运行的代码
行 155: EPR.Common.Service.ServiceManager.destroy();
行 156: //Appraise.Implement.CCal.Destroy();
行 157:
行 158: System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["EPRConnectionString_log"].ConnectionString.ToString().Trim());
行 159: EPR.Logon.eprCommon eprCommon = new EPR.Logon.eprCommon();
行 160: if (Application["total"] != null && Application["total"].ToString()!="")
行 161: eprCommon.ExecuteSQL("update t_ps01_counter set count=count+" + ((int)Application["total"] - (int)Application["total0"]), conn);
行 162: //string counter_file = System.Web.HttpContext.Current.Server.MapPath("~/counter/counter.txt");
行 163: //System.IO.StreamWriter sw = new System.IO.StreamWriter(counter_file, false);
行 164: //sw.WriteLine(Application["total"]);
行 165: //sw.Close();
行 166:
行 167: string IISlog_file = System.Web.HttpContext.Current.Server.MapPath("~/log/iisLog.txt");
行 168: if (!System.IO.File.Exists(IISlog_file))
行 169: {
行 170: System.IO.FileStream Fs = System.IO.File.Create(IISlog_file);
行 171: Fs.Close();
行 172: }
行 173: System.IO.StreamWriter sw = new System.IO.StreamWriter(IISlog_file, true);
行 174: sw.WriteLine(System.DateTime.Now.ToString() + " IIS停止");
行 175: sw.Close();
行 176: }
行 177:
行 178: void Application_Error(object sender, EventArgs e)
行 179: {
行 180: //Server.Transfer("~/error.aspx", true);
行 181: // 在出现未处理的错误时运行的代码
行 182: //if (Server.GetLastError() is HttpUnhandledException)
行 183: //Server.Transfer("~/error.aspx",true);
行 184: //Response.Redirect("error.aspx");
行 185: string errorPageSwich = System.Configuration.ConfigurationManager.AppSettings["ErrorPageSwitch"].ToString();
行 186: if (errorPageSwich == "false")
行 187: {
行 188: Exception lastError = Server.GetLastError().GetBaseException();
行 189: if (lastError.Message == "攻击")
行 190: {
行 191: Server.Transfer("~/error.aspx", true);
行 192: return;
行 193: }
行 194: if (lastError.Message == "没有权限")
行 195: {
行 196: EPR.Logon.Company Company = new EPR.Logon.Company();
行 197: EPR.Logon.Person Person = new EPR.Logon.Person();
行 198: EPR.Logon.LogUser LogUser = new EPR.Logon.LogUser();
行 199: EPR.Logon.SmUser SmUser = new EPR.Logon.SmUser();
行 200: EPR.Logon.RegCon RegCon = new EPR.Logon.RegCon();
行 201:
行 202: string sessionID = Session.SessionID;
行 203: if (Company.GetCompany(sessionID) != null) Company.RemoveCompany(sessionID);
行 204: if (Person.GetPerson(sessionID) != null) Person.RemovePerson(sessionID);
行 205:
行 206: if (LogUser.GetLogUser(sessionID) != null) LogUser.RemoveLogUser(sessionID);
行 207: if (SmUser.GetSmUser(sessionID) != null) SmUser.RemoveSmUser(sessionID);
行 208: if (RegCon.GetRegbase(sessionID) != null) RegCon.RemoveRegbase(sessionID);
行 209:
行 210: Server.Transfer("~/error.aspx", true);
行 211: return;
行 212: }
行 213: string dateString = DateTime.Now.Date.ToShortDateString();
行 214: string XMLfile = System.Web.HttpContext.Current.Server.MapPath("~/xml/" + dateString + ".XML");
行 215: if (!System.IO.File.Exists(XMLfile))
行 216: {
行 217: System.Xml.XmlDocument xml = new System.Xml.XmlDocument(); //建立XmlDomcument对象
行 218: xml.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?><Errors></Errors>");
行 219: xml.Save(XMLfile);
行 220: }
行 221:
行 222: System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); //建立XmlDomcument对象
行 223: xmlDoc.Load(XMLfile);
行 224: System.Xml.XmlElement root = xmlDoc.DocumentElement;
行 225:
行 226: System.Xml.XmlNode node1 = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "Error", "www-EPR-ErrorSystem");
行 227:
行 228: //root.AppendChild(node1);
行 229:
行 230: string stackString = "";
行 231:
行 232: if (lastError.StackTrace.IndexOf("在") >= 0)
行 233: {
行 234: string[] stackArray = lastError.StackTrace.Split("在".ToCharArray()[0]);
行 235: for (int i = 0; i <= stackArray.GetUpperBound(0); i++)
行 236: {
行 237: if (stackArray[i].IndexOf("行号") >= 0)
行 238: {
行 239: stackString = stackString + stackArray[i].ToString();
行 240: break;
行 241: }
行 242: else
行 243: {
行 244: stackString = stackString + stackArray[i].ToString();
行 245: }
行 246: }
行 247: }
行 248:
行 249: if (stackString == "") stackString = lastError.StackTrace;
行 250:
行 251:
行 252: node1.AppendChild(xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "日期", "www-EPR-ErrorSystem")).InnerText = DateTime.Now.ToString();
行 253: node1.Attributes.Append(xmlDoc.CreateAttribute("发生异常页")).InnerText = Request.Url.ToString();
行 254: node1.AppendChild(xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "异常信息", "www-EPR-ErrorSystem")).InnerText = lastError.Message;
行 255: node1.AppendChild(xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "异常跟踪", "www-EPR-ErrorSystem")).InnerText = lastError.StackTrace;
行 256: //node1.AppendChild(xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "异常方法名", "www-EPR-ErrorSystem")).InnerText = lastError.TargetSite.Name;
行 257: //node1.AppendChild(xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "异常类名", "www-EPR-ErrorSystem")).InnerText = lastError.TargetSite.DeclaringType.FullName;
行 258: root.InsertBefore(node1, root.FirstChild);
行 259: xmlDoc.Save(XMLfile);
行 260:
行 261:
行 262: //Server.ClearError();
行 263: }
行 264: else
行 265: {
行 266: Server.Transfer("~/error.aspx", true);
行 267: }
行 268: }
行 269:
行 270: void Session_Start(object sender, EventArgs e)
行 271: {
行 272:
行 273: //在新会话启动时运行的代码
行 274: Session.Timeout = 5;
行 275: if (Session["connected"] == null)
行 276: {
行 277: Application.Lock();
行 278: if (Application["total"]!=null) Application["total"] = (int)Application["total"] + 1;
行 279: if (Application["online"]!=null) Application["online"] = (int)Application["online"] + 1;
行 280:
行 281: System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["EPRConnectionString_log"].ConnectionString.ToString().Trim());
行 282: EPR.Logon.eprCommon eprCommon = new EPR.Logon.eprCommon();
行 283: if (Application["total"] != null && Application["total"].ToString() != "")
行 284: eprCommon.ExecuteSQL("update t_ps01_counter set count=" + (int)Application["total"],conn);
行 285: //string counter_file = System.Web.HttpContext.Current.Server.MapPath("~/counter/counter.txt");
行 286: //System.IO.StreamWriter sw = new System.IO.StreamWriter(counter_file, false);
行 287: //sw.WriteLine(Application["total"]);
行 288: //sw.Close();
行 289: Application.UnLock();
行 290: Session["connected"] = true;
行 291: }
行 292: }
行 293:
行 294: void Session_End(object sender, EventArgs e)
行 295: {
行 296: // 在会话结束时运行的代码。
行 297: // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
行 298: // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer
行 299: // 或 SQLServer,则不会引发该事件。
行 300:
行 301:
行 302:
行 303: Application.Lock();
行 304: Application["online"] = (int)Application["online"] - 1;
行 305: Application.UnLock();
行 306:
行 307: //释放内存
行 308: //EPR.Logon.eprCommon eprCommon = new EPR.Logon.eprCommon();
行 309: EPR.Logon.Company Company = new EPR.Logon.Company();
行 310: EPR.Logon.Person Person = new EPR.Logon.Person();
行 311: EPR.Logon.LogUser LogUser = new EPR.Logon.LogUser();
行 312: EPR.Logon.SmUser SmUser = new EPR.Logon.SmUser();
行 313: EPR.Logon.RegCon RegCon = new EPR.Logon.RegCon();
行 314: //EPR.Common.Permissions permissions = new EPR.Common.Permissions();
行 315: string sessionID = Session.SessionID;
行 316: if (EPR.Common.UserEnvironment.getUser(sessionID) != null)
行 317: {
行 318: //写入登录日志
行 319: EPR.Common.Log.log("用户超时登出", "Logout", EPR.Common.UserEnvironment.getUser(sessionID).ID, EPR.Common.UserEnvironment.getUser(sessionID).Name, EPR.Common.UserEnvironment.getUser(sessionID).IP);
行 320: //System.Collections.Hashtable table = EPR.Common.UserEnvironment.getUsersTable();
行 321: //if (table.Contains(sessionID)) table.Remove(sessionID);
行 322: EPR.Common.UserEnvironment.releaseUser(sessionID);
行 323: }
行 324: if (Company.GetCompany(sessionID) != null) Company.RemoveCompany(sessionID);
行 325: if (Person.GetPerson(sessionID) != null) Person.RemovePerson(sessionID);
行 326:
行 327: if (LogUser.GetLogUser(sessionID) != null) LogUser.RemoveLogUser(sessionID);
行 328: if (SmUser.GetSmUser(sessionID) != null) SmUser.RemoveSmUser(sessionID);
行 329: if (RegCon.GetRegbase(sessionID) != null) RegCon.RemoveRegbase(sessionID);
行 330:
行 331: //if (permissions.GetSPermission(sessionID) != null) permissions.RemoveSPermission(sessionID);
行 332: }
行 333:
行 334: protected void Application_BeginRequest(object sender, EventArgs e)
行 335: {
行 336: if(Request.Url.AbsoluteUri.IndexOf("\~\*") >= 0 )
行 337: throw new Exception("攻击");
行 338:
行 339: String[] keys = Request.Params.AllKeys;
行 340: for (int i = 0; i < keys.Length; i++)
行 341: {
行 342: String value = Request.Params[keys[i]].ToLower();
行 343:
行 344: //记录攻击到数据库
行 345: //EPR.Logon.eprCommon eprCommon = new EPR.Logon.eprCommon();
行 346: //System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["EPRConnectionString_log"].ConnectionString.ToString().Trim());
行 347:
行 348: //object obj = eprCommon.ExecuteSelectSQL("select OpenHoldFuck from t_ps01_HoldFuck", conn);
行 349: //if (obj != null && (int)obj==1)
行 350: //{
行 351: //eprCommon.ExecuteSQL("insert into t_ps01_HoldFuckMemo (memo,addtime) values('" + value + "','" + DateTime.Now + "')", conn);
行 352: //}
行 353:
行 354:
行 355: if (value.IndexOf("<script") >= 0 || value.IndexOf("<iframe") >= 0 || (value.IndexOf("update ") >= 0 && value.IndexOf("autoupdate ") < 0) || value.IndexOf("delete ") >= 0 || value.IndexOf("cast(") >= 0 || value.IndexOf("exec(") >= 0 || value.IndexOf("xp_cmdshell") >= 0 || value.IndexOf("select ") >= 0 || value.IndexOf("insert ") >= 0 || value.IndexOf("drop ") >= 0 || value.IndexOf("truncate ") >= 0 || value.IndexOf("master") >= 0 || value.IndexOf("declare ") >= 0 || value.IndexOf("create ") >= 0 || value.IndexOf("alter ") >= 0)
行 356: //if (value.IndexOf("<script") >= 0 || value.IndexOf("<iframe") >= 0)
行 357: {
行 358: if (value.IndexOf("select fjsj") < 0) //设计合同导出Excel 的特殊情况
行 359: {
行 360: string urlstring = Request.Url.ToString();
行 361: string fuck_file = System.Web.HttpContext.Current.Server.MapPath("~/log/Fucklog.txt");
行 362: if (!System.IO.File.Exists(fuck_file))
行 363: {
行 364: System.IO.FileStream Fs = System.IO.File.Create(fuck_file);
行 365: Fs.Close();
行 366: }
行 367: System.IO.StreamWriter sw = new System.IO.StreamWriter(fuck_file, true);
行 368: sw.WriteLine(System.DateTime.Now.ToString() + " IP: " + Request.UserHostAddress + " " + urlstring + " -- PostValue:【" + value + "】");
行 369: sw.Close();
行 370:
行 371: Response.Redirect("~/error.aspx?a=fuck");
行 372: //throw new Exception("攻击");
行 373: }
行 374: }
行 375: }
行 376: }
行 377: protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
行 378: {
行 379: //Response.Write(Request.RawUrl);
行 380:
行 381: //取得当前用户正在访问的专项业务
行 382: //if (EPR.Common.UserEnvironment.getUser(Session.SessionID) != null)
行 383: //{
行 384: // string zxyw = EPR.Common.UserEnvironment.getUser(Session.SessionID).Functioncode;
行 385: // //取得用户将要访问的专项业务路径
行 386: // string url = Request.RawUrl.Replace("/","_").Replace("\\","_");
行 387: // if (zxyw!=null && zxyw!="" && url.IndexOf(zxyw) < 0)
行 388: // {
行 389: // // 清除所有属性
行 390: // EPR.Common.UserEnvironment.clear();
行 391: // // 或,清除部分属性,例如,清除以“R02”起始的属性
行 392: // //EPR.Common.UserEnvironment.clear("R02");
行 393: // }
行 394:
行 395: //}
行 396: }
行 397:
行 398:
行 399: #line default
行 400: #line hidden
行 401:
行 402:
行 403: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
行 404: public global_asax() {
行 405: if ((global::ASP.global_asax.@__initialized == false)) {
行 406: global::ASP.global_asax.@__initialized = true;
行 407: }
行 408: }
行 409:
行 410: protected System.Web.Profile.DefaultProfile Profile {
行 411: get {
行 412: return ((System.Web.Profile.DefaultProfile)(this.Context.Profile));
行 413: }
行 414: }
行 415: }
行 416: }
行 417:
|