|
|
@@ -53,7 +53,7 @@ class WebServer extends Worker
|
|
|
*/
|
|
|
public function addRoot($domain, $config)
|
|
|
{
|
|
|
- if (is_string($config)) {
|
|
|
+ if (\is_string($config)) {
|
|
|
$config = array('root' => $config);
|
|
|
}
|
|
|
$this->serverRoot[$domain] = $config;
|
|
|
@@ -126,7 +126,7 @@ class WebServer extends Worker
|
|
|
$this->log("$mime_file mime.type file not fond");
|
|
|
return;
|
|
|
}
|
|
|
- $items = \file($mime_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
|
+ $items = \file($mime_file, \FILE_IGNORE_NEW_LINES | \FILE_SKIP_EMPTY_LINES);
|
|
|
if (!\is_array($items)) {
|
|
|
$this->log("get $mime_file mime.type content fail");
|
|
|
return;
|
|
|
@@ -172,7 +172,7 @@ class WebServer extends Worker
|
|
|
$workerman_file_extension = 'php';
|
|
|
}
|
|
|
|
|
|
- $workerman_siteConfig = isset($this->serverRoot[$_SERVER['SERVER_NAME']]) ? $this->serverRoot[$_SERVER['SERVER_NAME']] : current($this->serverRoot);
|
|
|
+ $workerman_siteConfig = isset($this->serverRoot[$_SERVER['SERVER_NAME']]) ? $this->serverRoot[$_SERVER['SERVER_NAME']] : \current($this->serverRoot);
|
|
|
$workerman_root_dir = $workerman_siteConfig['root'];
|
|
|
$workerman_file = "$workerman_root_dir/$workerman_path";
|
|
|
if(isset($workerman_siteConfig['additionHeader'])){
|
|
|
@@ -205,7 +205,7 @@ class WebServer extends Worker
|
|
|
|
|
|
// Request php file.
|
|
|
if ($workerman_file_extension === 'php') {
|
|
|
- $workerman_cwd = getcwd();
|
|
|
+ $workerman_cwd = \getcwd();
|
|
|
\chdir($workerman_root_dir);
|
|
|
\ini_set('display_errors', 'off');
|
|
|
\ob_start();
|
|
|
@@ -237,7 +237,7 @@ class WebServer extends Worker
|
|
|
} else {
|
|
|
// 404
|
|
|
Http::header("HTTP/1.1 404 Not Found");
|
|
|
- if(isset($workerman_siteConfig['custom404']) && file_exists($workerman_siteConfig['custom404'])){
|
|
|
+ if(isset($workerman_siteConfig['custom404']) && \file_exists($workerman_siteConfig['custom404'])){
|
|
|
$html404 = \file_get_contents($workerman_siteConfig['custom404']);
|
|
|
}else{
|
|
|
$html404 = '<html><head><title>404 File not found</title></head><body><center><h3>404 Not Found</h3></center></body></html>';
|
|
|
@@ -254,7 +254,7 @@ class WebServer extends Worker
|
|
|
public static function sendFile($connection, $file_path)
|
|
|
{
|
|
|
// Check 304.
|
|
|
- $info = stat($file_path);
|
|
|
+ $info = \stat($file_path);
|
|
|
$modified_time = $info ? \date('D, d M Y H:i:s', $info['mtime']) . ' ' . \date_default_timezone_get() : '';
|
|
|
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $info) {
|
|
|
// Http 304.
|
|
|
@@ -283,12 +283,12 @@ class WebServer extends Worker
|
|
|
if (isset(self::$mimeTypeMap[$extension])) {
|
|
|
$header .= "Content-Type: " . self::$mimeTypeMap[$extension] . "\r\n";
|
|
|
} else {
|
|
|
- $header .= "Content-Type: application/octet-stream\r\n";
|
|
|
- $header .= "Content-Disposition: attachment; filename=\"$file_name\"\r\n";
|
|
|
+ $header .= "Content-Type: application/octet-stream\r\n"
|
|
|
+ ."Content-Disposition: attachment; filename=\"$file_name\"\r\n";
|
|
|
}
|
|
|
- $header .= "Connection: keep-alive\r\n";
|
|
|
- $header .= $modified_time;
|
|
|
- $header .= "Content-Length: $file_size\r\n\r\n";
|
|
|
+ $header .= "Connection: keep-alive\r\n"
|
|
|
+ .$modified_time
|
|
|
+ ."Content-Length: $file_size\r\n\r\n";
|
|
|
$trunk_limit_size = 1024*1024;
|
|
|
if ($file_size < $trunk_limit_size) {
|
|
|
return $connection->send($header.\file_get_contents($file_path), true);
|