extention.func.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * extention.func.php 用户自定义函数库
  4. *
  5. * @copyright (C) 2005-2010 PHPCMS
  6. * @license http://www.phpcms.cn/license/
  7. * @lastmodify 2010-10-27
  8. */
  9. /**
  10. * 通过username值,查询真实姓名
  11. */
  12. function get_admin_realname($username) {
  13. if(empty($username)){return false;}
  14. $admin_db = pc_base::load_model('admin_model');
  15. $realname = $admin_db->get_one(array('username'=>$username),'realname');
  16. //如果没有真实姓名返回用户名
  17. if($realname['realname']) {
  18. return $realname['realname'];
  19. } else {
  20. return $username;
  21. }
  22. }
  23. function is_mobile() {
  24. $user_agent = $_SERVER ['HTTP_USER_AGENT'];
  25. $mobile_browser = Array (
  26. "mqqbrowser", // 手机QQ浏览器
  27. "opera mobi", // 手机opera
  28. "juc", "iuc", // uc浏览器
  29. "fennec",
  30. "ios",
  31. "applewebKit/420",
  32. "applewebkit/525",
  33. "applewebkit/532",
  34. "ipad",
  35. "iphone",
  36. "ipaq",
  37. "ipod",
  38. "iemobile",
  39. "windows ce", // windows phone
  40. "240×320",
  41. "480×640",
  42. "acer",
  43. "android",
  44. "anywhereyougo.com",
  45. "asus",
  46. "audio",
  47. "blackberry",
  48. "blazer",
  49. "coolpad",
  50. "dopod",
  51. "etouch",
  52. "hitachi",
  53. "htc",
  54. "huawei",
  55. "jbrowser",
  56. "lenovo",
  57. "lg",
  58. "lg-",
  59. "lge-",
  60. "lge",
  61. "mobi",
  62. "moto",
  63. "nokia",
  64. "phone",
  65. "samsung",
  66. "sony",
  67. "symbian",
  68. "tablet",
  69. "tianyu",
  70. "wap",
  71. "xda",
  72. "xde",
  73. "zte"
  74. );
  75. $is_mobile = false;
  76. foreach ( $mobile_browser as $device ) {
  77. if (stristr ( $user_agent, $device )) {
  78. $is_mobile = true;
  79. break;
  80. }
  81. }
  82. return $is_mobile;
  83. }
  84. ?>