浏览代码

Check for Empty User Agent before Comparing

Andy 2 年之前
父节点
当前提交
c85b5da58f
共有 1 个文件被更改,包括 11 次插入9 次删除
  1. 11 9
      functions/template/general_util.php

+ 11 - 9
functions/template/general_util.php

@@ -35,15 +35,17 @@ function create_css_link($uri, $name='', $alt=TRUE, $mtype='screen') {
 
     sqGetGlobalVar('HTTP_USER_AGENT', $browser_user_agent, SQ_SERVER);
 
-    if (stristr($browser_user_agent, "msie 4")) {
-        $browser = 'msie4';
-        $dom_browser = false;
-        $is_IE = true;
-    } elseif (stristr($browser_user_agent, "msie") 
-           && stristr($browser_user_agent, 'opera') === FALSE) {
-        $browser = 'msie';
-        $dom_browser = true;
-        $is_IE = true;
+    if (!empty($browser_user_agent)) {
+        if (stristr($browser_user_agent, "msie 4")) {
+            $browser = 'msie4';
+            $dom_browser = false;
+            $is_IE = true;
+        } elseif (stristr($browser_user_agent, "msie") 
+               && stristr($browser_user_agent, 'opera') === FALSE) {
+            $browser = 'msie';
+            $dom_browser = true;
+            $is_IE = true;
+        }
     }
 
     if ((strpos($uri, '-ie')!== false) and !$is_IE) {