BasePage.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*******************************************************************************
  2. * iNethinkCMS - 网站内容管理系统
  3. * Copyright (C) 2012-2013 inethink.com
  4. *
  5. * @author jackyang <69991000@qq.com>
  6. * @website http://cms.inethink.com
  7. * @version 1.3.6.0 (2013-08-14)
  8. *
  9. * This is licensed under the GNU LGPL, version 3.0 or later.
  10. * For details, see: http://www.gnu.org/licenses/gpl-3.0.html
  11. *******************************************************************************/
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Text;
  15. namespace iNethinkCMS.Web.UI
  16. {
  17. public class BasePage : System.Web.UI.Page
  18. {
  19. public Model.Model_Config siteConfig = new Model.Model_Config();
  20. protected Model.Model_Config seoConfig = new Model.Model_Config();
  21. override protected void OnInit(EventArgs e)
  22. {
  23. //Server.ScriptTimeout = 90; //默认脚本过期时间
  24. siteConfig = new BLL.BLL_Config().GetModel_SysConfig(); //获取站点配置信息
  25. seoConfig = new BLL.BLL_Config().GetModel_SeoConfig(); //获取SEO配置信息
  26. base.OnInit(e);
  27. }
  28. #region 对用户访问进行判断 如果是手机的话返回true,否则返回false
  29. protected string[] Keywords = {
  30. "Noki","Eric", "WapI", "MC21",
  31. "AUR", "R380","UP.B","WinW",
  32. "UPG1","upsi","QWAP","Jigs",
  33. "Java","Alca","MITS","MOT-",
  34. "My S","WAPJ","fetc","ALAV",
  35. "Wapa","UCWEB","BlackBerry",
  36. "J2ME","Oper","Android","mozilla",
  37. "NetFront","UCWEB","iPhone","Windows CE",
  38. "MIDP-2.0","Android","Opera Mini",
  39. "SymbianOS","Windows Phone","iPad"
  40. };
  41. protected bool isMobile()
  42. {
  43. string agent = Request.Headers["User-Agent"];
  44. return isMobile(agent);
  45. }
  46. protected bool isMobile(String userAgent)
  47. {
  48. foreach (string keyword in Keywords)
  49. {
  50. if (userAgent.IndexOf(keyword) > -1)
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. #endregion
  58. }
  59. }