Selaa lähdekoodia

Fixed:warning

Zhu Jinhui 6 vuotta sitten
vanhempi
commit
3ad86fcdd1
3 muutettua tiedostoa jossa 13 lisäystä ja 8 poistoa
  1. 4 1
      src/Cache/Memcached.php
  2. 2 4
      src/Library/Download.php
  3. 7 3
      src/Request/Url/Base.php

+ 4 - 1
src/Cache/Memcached.php

@@ -106,7 +106,10 @@ class Memcached implements Intf
 
         if($this->_conn instanceof \Memcache || $this->_conn instanceof \Memcached){
             $data = serialize($data);
-            return $this->_conn->set($id, $data, MEMCACHE_COMPRESSED, $this->_default_policy['life_time']);
+            if($this->_conn instanceof \Memcache) {
+                return $this->_conn->set($id, $data, MEMCACHE_COMPRESSED, $this->_default_policy['life_time']);
+            }
+            return $this->_conn->set($id, $data, $this->_default_policy['life_time']);
         }
         return $this->_conn->set($id, $data, $this->_default_policy['life_time']);
     }

+ 2 - 4
src/Library/Download.php

@@ -2,7 +2,7 @@
 namespace Qii\Library;
 
 set_time_limit (0);
-//ignore_user_abort(true);
+ignore_user_abort(false);
 class Download
 {
 	const VERSION = 1.0;
@@ -98,9 +98,7 @@ class Download
 	 */
 	public function download($filePath, $fileName = '', $mime = '', $view = 'download')
 	{
-		//设定不限制时间
-		ignore_user_abort(false);
-		set_time_limit(0);
+
 		//转换文件路为GBK,避免无法访问中文文件
 		$filePath = toGBK($filePath);
 		if(!file_exists($filePath))

+ 7 - 3
src/Request/Url/Base.php

@@ -49,6 +49,8 @@ abstract class Base
 	 */
 	private $pathArgs;
 
+	public $host;
+
     /**
      * 初始化模式
      * @param string $mode 模式
@@ -61,6 +63,7 @@ abstract class Base
             $this->_symbol = '/';
         }
         $this->params = $this->getParams();
+        $this->host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
     }
 
     /**
@@ -131,7 +134,7 @@ abstract class Base
         if (IS_CLI) return '';
         $prefix = 'http://';
         if ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || $_SERVER['SERVER_PORT'] == 443) $prefix = 'https://';
-        return $prefix . rtrim(rtrim(str_replace('//', '/', $_SERVER['HTTP_HOST']), '/'), "\\");
+        return $prefix . rtrim(rtrim(str_replace('//', '/', $this->host), '/'), "\\");
     }
 
     /**
@@ -139,7 +142,8 @@ abstract class Base
      */
     public function getDomain()
     {
-        return rtrim(rtrim(str_replace('//', '/', $_SERVER['HTTP_HOST']), '/'), "\\");
+        if (IS_CLI) return '';
+        return rtrim(rtrim(str_replace('//', '/', $this->host), '/'), "\\");
     }
 
     /**
@@ -149,7 +153,7 @@ abstract class Base
     public function getCurrentURL()
     {
         if (IS_CLI) return '';
-        return 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+        return 'http://' . $this->host . $_SERVER['REQUEST_URI'];
     }
 
     /**