repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
matyhtf/framework | libs/Swoole/Network/Stream.php | Stream.close | static function close($socket,$event=null)
{
if($event)
{
event_del($event);
event_free($event);
}
fclose($socket);
} | php | static function close($socket,$event=null)
{
if($event)
{
event_del($event);
event_free($event);
}
fclose($socket);
} | [
"static",
"function",
"close",
"(",
"$",
"socket",
",",
"$",
"event",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"event",
")",
"{",
"event_del",
"(",
"$",
"event",
")",
";",
"event_free",
"(",
"$",
"event",
")",
";",
"}",
"fclose",
"(",
"$",
"socket"... | 关闭socket
@param $socket
@param $event
@return unknown_type | [
"关闭socket"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Network/Stream.php#L12-L20 |
matyhtf/framework | libs/Swoole/Network/Stream.php | Stream.read | static function read($fp,$length)
{
$data = '';
while($buf = fread($fp, $length))
{
$data .= $buf;
if(strlen($buf) < $length) break;
}
return $data;
} | php | static function read($fp,$length)
{
$data = '';
while($buf = fread($fp, $length))
{
$data .= $buf;
if(strlen($buf) < $length) break;
}
return $data;
} | [
"static",
"function",
"read",
"(",
"$",
"fp",
",",
"$",
"length",
")",
"{",
"$",
"data",
"=",
"''",
";",
"while",
"(",
"$",
"buf",
"=",
"fread",
"(",
"$",
"fp",
",",
"$",
"length",
")",
")",
"{",
"$",
"data",
".=",
"$",
"buf",
";",
"if",
"(... | 非阻塞循环读取,不能用于阻塞socket
@param $fp
@param $length
@return string | [
"非阻塞循环读取,不能用于阻塞socket"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Network/Stream.php#L28-L37 |
matyhtf/framework | libs/Swoole/SiteDict.php | SiteDict.get | static function get($dictname)
{
if(!\Swoole::$php->cache) Error::info('SiteDict Cache Error','Please load Cache!');
$cache_key = 'sitedict_'.$dictname;
$$dictname = \Swoole::$php->cache->get($cache_key);
if(empty($$dictname))
{
$data_file = self::$data_dir.'/'.$dictname.'.php';
if(!file_exists($data_f... | php | static function get($dictname)
{
if(!\Swoole::$php->cache) Error::info('SiteDict Cache Error','Please load Cache!');
$cache_key = 'sitedict_'.$dictname;
$$dictname = \Swoole::$php->cache->get($cache_key);
if(empty($$dictname))
{
$data_file = self::$data_dir.'/'.$dictname.'.php';
if(!file_exists($data_f... | [
"static",
"function",
"get",
"(",
"$",
"dictname",
")",
"{",
"if",
"(",
"!",
"\\",
"Swoole",
"::",
"$",
"php",
"->",
"cache",
")",
"Error",
"::",
"info",
"(",
"'SiteDict Cache Error'",
",",
"'Please load Cache!'",
")",
";",
"$",
"cache_key",
"=",
"'sited... | 读取字典内容
@param $dictname | [
"读取字典内容"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/SiteDict.php#L25-L38 |
matyhtf/framework | libs/Swoole/SiteDict.php | SiteDict.set | static function set($dictname,$dict)
{
if(!\Swoole::$php->cache) Error::info('SiteDict Cache Error','Please load Cache!');
$filename = self::$data_dir.'/'.$dictname.'.php';
self::write($dictname,$dict,$filename);
self::delete($dictname);
} | php | static function set($dictname,$dict)
{
if(!\Swoole::$php->cache) Error::info('SiteDict Cache Error','Please load Cache!');
$filename = self::$data_dir.'/'.$dictname.'.php';
self::write($dictname,$dict,$filename);
self::delete($dictname);
} | [
"static",
"function",
"set",
"(",
"$",
"dictname",
",",
"$",
"dict",
")",
"{",
"if",
"(",
"!",
"\\",
"Swoole",
"::",
"$",
"php",
"->",
"cache",
")",
"Error",
"::",
"info",
"(",
"'SiteDict Cache Error'",
",",
"'Please load Cache!'",
")",
";",
"$",
"file... | 写入字典内容
@param $dictname | [
"写入字典内容"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/SiteDict.php#L43-L49 |
matyhtf/framework | libs/Swoole/HTML.php | HTML.parseRelativePath | static function parseRelativePath($current, $url)
{
//非HTTP开头的,相对路径
if (substr($url, 0, 7) !== 'http://' and substr($url, 0, 8) !== 'https://' )
{
//以/开头的
if ($url[0] == '/')
{
$_u = parse_url($current);
return $_u['scheme'... | php | static function parseRelativePath($current, $url)
{
//非HTTP开头的,相对路径
if (substr($url, 0, 7) !== 'http://' and substr($url, 0, 8) !== 'https://' )
{
//以/开头的
if ($url[0] == '/')
{
$_u = parse_url($current);
return $_u['scheme'... | [
"static",
"function",
"parseRelativePath",
"(",
"$",
"current",
",",
"$",
"url",
")",
"{",
"//非HTTP开头的,相对路径",
"if",
"(",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"7",
")",
"!==",
"'http://'",
"and",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"8",
"... | 解析相对路径
@param $current
@param $url
@return string | [
"解析相对路径"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/HTML.php#L51-L72 |
matyhtf/framework | libs/Swoole/HTML.php | HTML.removeTag | static function removeTag($html, $rules = array('script', 'style'))
{
//file_put_contents('tmp2.html', $html);
foreach($rules as $r)
{
while(1)
{
$search1 = '<'.$r;
$pos1 = stripos($html, $search1);
if ($pos1 === false)... | php | static function removeTag($html, $rules = array('script', 'style'))
{
//file_put_contents('tmp2.html', $html);
foreach($rules as $r)
{
while(1)
{
$search1 = '<'.$r;
$pos1 = stripos($html, $search1);
if ($pos1 === false)... | [
"static",
"function",
"removeTag",
"(",
"$",
"html",
",",
"$",
"rules",
"=",
"array",
"(",
"'script'",
",",
"'style'",
")",
")",
"{",
"//file_put_contents('tmp2.html', $html);",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"r",
")",
"{",
"while",
"(",
"1",
"... | 删除HTML中的某些标签
@param $html
@param array $rules
@return mixed | [
"删除HTML中的某些标签"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/HTML.php#L80-L109 |
matyhtf/framework | libs/Swoole/HTML.php | HTML.removeAttr | static function removeAttr($html, $remove_attrs = array())
{
//删除所有属性
if (!is_array($remove_attrs) or count($remove_attrs) == 0)
{
return preg_replace('~<([a-z]+)[^>]*>~i','<$1>', $html);
}
//删除部分指定的属性
else
{
foreach($remove_attrs as $a... | php | static function removeAttr($html, $remove_attrs = array())
{
//删除所有属性
if (!is_array($remove_attrs) or count($remove_attrs) == 0)
{
return preg_replace('~<([a-z]+)[^>]*>~i','<$1>', $html);
}
//删除部分指定的属性
else
{
foreach($remove_attrs as $a... | [
"static",
"function",
"removeAttr",
"(",
"$",
"html",
",",
"$",
"remove_attrs",
"=",
"array",
"(",
")",
")",
"{",
"//删除所有属性",
"if",
"(",
"!",
"is_array",
"(",
"$",
"remove_attrs",
")",
"or",
"count",
"(",
"$",
"remove_attrs",
")",
"==",
"0",
")",
"{"... | 删除HTML中的tag属性
@param $html
@param array $remove_attrs
@return mixed | [
"删除HTML中的tag属性"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/HTML.php#L117-L135 |
matyhtf/framework | libs/Swoole/Server/Base.php | Base.setProtocol | function setProtocol($protocol)
{
if (!($protocol instanceof Swoole\IFace\Protocol))
{
throw new \Exception("The protocol is not instanceof \\Swoole\\IFace\\Protocol");
}
$this->protocol = $protocol;
$protocol->server = $this;
} | php | function setProtocol($protocol)
{
if (!($protocol instanceof Swoole\IFace\Protocol))
{
throw new \Exception("The protocol is not instanceof \\Swoole\\IFace\\Protocol");
}
$this->protocol = $protocol;
$protocol->server = $this;
} | [
"function",
"setProtocol",
"(",
"$",
"protocol",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"protocol",
"instanceof",
"Swoole",
"\\",
"IFace",
"\\",
"Protocol",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"The protocol is not instanceof \\\\Swoole\\\\IFace... | 设置通信协议
@param $protocol
@throws \Exception | [
"设置通信协议"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Server/Base.php#L86-L94 |
matyhtf/framework | libs/Swoole/Server/Base.php | Base.accept | function accept()
{
$client_socket = stream_socket_accept($this->server_sock, 0);
//惊群
if ($client_socket === false)
{
return false;
}
$client_socket_id = (int)$client_socket;
stream_set_blocking($client_socket, $this->client_block);
$this-... | php | function accept()
{
$client_socket = stream_socket_accept($this->server_sock, 0);
//惊群
if ($client_socket === false)
{
return false;
}
$client_socket_id = (int)$client_socket;
stream_set_blocking($client_socket, $this->client_block);
$this-... | [
"function",
"accept",
"(",
")",
"{",
"$",
"client_socket",
"=",
"stream_socket_accept",
"(",
"$",
"this",
"->",
"server_sock",
",",
"0",
")",
";",
"//惊群",
"if",
"(",
"$",
"client_socket",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"cli... | 接受连接
@return bool|int | [
"接受连接"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Server/Base.php#L117-L140 |
matyhtf/framework | libs/Swoole/Server/Base.php | Base.create | function create($uri, $block = 0)
{
//UDP
if ($uri{0} == 'u')
{
$socket = stream_socket_server($uri, $errno, $errstr, STREAM_SERVER_BIND);
}
//TCP
else
{
$socket = stream_socket_server($uri, $errno, $errstr);
}
if (!$so... | php | function create($uri, $block = 0)
{
//UDP
if ($uri{0} == 'u')
{
$socket = stream_socket_server($uri, $errno, $errstr, STREAM_SERVER_BIND);
}
//TCP
else
{
$socket = stream_socket_server($uri, $errno, $errstr);
}
if (!$so... | [
"function",
"create",
"(",
"$",
"uri",
",",
"$",
"block",
"=",
"0",
")",
"{",
"//UDP",
"if",
"(",
"$",
"uri",
"{",
"0",
"}",
"==",
"'u'",
")",
"{",
"$",
"socket",
"=",
"stream_socket_server",
"(",
"$",
"uri",
",",
"$",
"errno",
",",
"$",
"errst... | 创建一个Stream Server Socket
@param $uri
@return resource | [
"创建一个Stream",
"Server",
"Socket"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Server/Base.php#L239-L259 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_PWD | function cmd_PWD($fd, $cmd)
{
$user = $this->getUser($fd);
$this->send($fd, "257 \"" . $this->getUserDir($user) . "\" is your current location");
} | php | function cmd_PWD($fd, $cmd)
{
$user = $this->getUser($fd);
$this->send($fd, "257 \"" . $this->getUserDir($user) . "\" is your current location");
} | [
"function",
"cmd_PWD",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
")",
";",
"$",
"this",
"->",
"send",
"(",
"$",
"fd",
",",
"\"257 \\\"\"",
".",
"$",
"this",
"->",
"getUserDir",
"(... | 获取当前目录
@param $fd
@param $cmd | [
"获取当前目录"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L63-L67 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_CWD | function cmd_CWD($fd, $cmd)
{
$user = $this->getUser($fd);
if (($dir = $this->setUserDir($user, $cmd[1])) != false)
{
$this->send($fd, "250 OK. Current directory is " . $dir);
}
else
{
$this->send($fd, "550 Can't change directory to " . $cmd[1]... | php | function cmd_CWD($fd, $cmd)
{
$user = $this->getUser($fd);
if (($dir = $this->setUserDir($user, $cmd[1])) != false)
{
$this->send($fd, "250 OK. Current directory is " . $dir);
}
else
{
$this->send($fd, "550 Can't change directory to " . $cmd[1]... | [
"function",
"cmd_CWD",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
")",
";",
"if",
"(",
"(",
"$",
"dir",
"=",
"$",
"this",
"->",
"setUserDir",
"(",
"$",
"user",
",",
"$",
"cmd",
... | 更改当前目录
@param $fd
@param $cmd | [
"更改当前目录"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L74-L85 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_STOR | function cmd_STOR($fd, $cmd)
{
$user = $this->getUser($fd);
$ftpsock = $this->getUserSock($user);
$file = $this->fillDirName($user, $cmd[1]);
$this->debug("PUT: $file");
$fp = fopen($file, "w");
if (!$fp)
{
$this->send($fd, "553 Can't open that fil... | php | function cmd_STOR($fd, $cmd)
{
$user = $this->getUser($fd);
$ftpsock = $this->getUserSock($user);
$file = $this->fillDirName($user, $cmd[1]);
$this->debug("PUT: $file");
$fp = fopen($file, "w");
if (!$fp)
{
$this->send($fd, "553 Can't open that fil... | [
"function",
"cmd_STOR",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
")",
";",
"$",
"ftpsock",
"=",
"$",
"this",
"->",
"getUserSock",
"(",
"$",
"user",
")",
";",
"$",
"file",
"=",
... | 上传文件
@param $fd
@param $cmd | [
"上传文件"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L92-L121 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_RMD | function cmd_RMD($fd, $cmd)
{
$user = $this->getUser($fd);
$dir = $this->fillDirName($user, $cmd[1]);
$this->debug("RMDIR: $dir");
if (is_dir(dirname($dir)) and is_dir($dir))
{
if (count(glob($dir . "/*")))
{
$this->send($fd, "550 Can't... | php | function cmd_RMD($fd, $cmd)
{
$user = $this->getUser($fd);
$dir = $this->fillDirName($user, $cmd[1]);
$this->debug("RMDIR: $dir");
if (is_dir(dirname($dir)) and is_dir($dir))
{
if (count(glob($dir . "/*")))
{
$this->send($fd, "550 Can't... | [
"function",
"cmd_RMD",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
")",
";",
"$",
"dir",
"=",
"$",
"this",
"->",
"fillDirName",
"(",
"$",
"user",
",",
"$",
"cmd",
"[",
"1",
"]",
... | 删除目录
@param $fd
@param $cmd | [
"删除目录"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L128-L156 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_DELE | function cmd_DELE($fd, $cmd)
{
$user = $this->getUser($fd);
$file = $this->fillDirName($user, $cmd[1]);
$this->debug("DEL: $file");
if (!file_exists($file))
{
$this->send($fd, "550 Could not delete " . $cmd[1] . ": No such file or directory");
}
el... | php | function cmd_DELE($fd, $cmd)
{
$user = $this->getUser($fd);
$file = $this->fillDirName($user, $cmd[1]);
$this->debug("DEL: $file");
if (!file_exists($file))
{
$this->send($fd, "550 Could not delete " . $cmd[1] . ": No such file or directory");
}
el... | [
"function",
"cmd_DELE",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"fillDirName",
"(",
"$",
"user",
",",
"$",
"cmd",
"[",
"1",
"]",... | 删除文件
@param $fd
@param $cmd | [
"删除文件"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L163-L180 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_MKD | function cmd_MKD($fd, $cmd)
{
$user = $this->getUser($fd);
$path = $this->getAbsDir($user).$cmd[1];
if (!is_dir(dirname($path)))
{
$this->send($fd, "550 Can't create directory: No such file or directory");
}
elseif(file_exists($path))
{
... | php | function cmd_MKD($fd, $cmd)
{
$user = $this->getUser($fd);
$path = $this->getAbsDir($user).$cmd[1];
if (!is_dir(dirname($path)))
{
$this->send($fd, "550 Can't create directory: No such file or directory");
}
elseif(file_exists($path))
{
... | [
"function",
"cmd_MKD",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"getAbsDir",
"(",
"$",
"user",
")",
".",
"$",
"cmd",
"[",
"1",
... | 创建目录
@param $fd
@param $cmd | [
"创建目录"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L197-L221 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_RNTO | function cmd_RNTO($fd, $cmd)
{
$user = $this->getUser($fd);
$old_file = $this->users[$user]['rename'];
$new_file = $this->fillDirName($user, $cmd[1]);
$this->debug("RENAME: $old_file to $new_file");
if (empty($old_file) or !is_dir(dirname($new_file)))
{
$t... | php | function cmd_RNTO($fd, $cmd)
{
$user = $this->getUser($fd);
$old_file = $this->users[$user]['rename'];
$new_file = $this->fillDirName($user, $cmd[1]);
$this->debug("RENAME: $old_file to $new_file");
if (empty($old_file) or !is_dir(dirname($new_file)))
{
$t... | [
"function",
"cmd_RNTO",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
")",
";",
"$",
"old_file",
"=",
"$",
"this",
"->",
"users",
"[",
"$",
"user",
"]",
"[",
"'rename'",
"]",
";",
"... | 文件重命名,目标文件
@param $fd
@param $cmd | [
"文件重命名",
"目标文件"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L228-L247 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_RNFR | function cmd_RNFR($fd, $cmd)
{
$user = $this->getUser($fd);
$file = $this->fillDirName($user, $cmd[1]);
if (!file_exists($file))
{
$this->send($fd, "550 Sorry, but that file doesn't exist");
}
else
{
$this->users[$user]['rename'] = $fil... | php | function cmd_RNFR($fd, $cmd)
{
$user = $this->getUser($fd);
$file = $this->fillDirName($user, $cmd[1]);
if (!file_exists($file))
{
$this->send($fd, "550 Sorry, but that file doesn't exist");
}
else
{
$this->users[$user]['rename'] = $fil... | [
"function",
"cmd_RNFR",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"fillDirName",
"(",
"$",
"user",
",",
"$",
"cmd",
"[",
"1",
"]",... | 文件重命名,源文件
@param $fd
@param $cmd | [
"文件重命名",
"源文件"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L254-L267 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_SITE | function cmd_SITE($fd, $cmd)
{
if (substr($cmd[1], 0, 6) == "CHMOD ")
{
$user = $this->getUser($fd);
$chmod = explode(" ", $cmd[1], 3);
$file = $this->fillDirName($user, $chmod[2]);
$this->debug("CHMOD: $file to {$chmod[1]}");
if (chmod($fi... | php | function cmd_SITE($fd, $cmd)
{
if (substr($cmd[1], 0, 6) == "CHMOD ")
{
$user = $this->getUser($fd);
$chmod = explode(" ", $cmd[1], 3);
$file = $this->fillDirName($user, $chmod[2]);
$this->debug("CHMOD: $file to {$chmod[1]}");
if (chmod($fi... | [
"function",
"cmd_SITE",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"cmd",
"[",
"1",
"]",
",",
"0",
",",
"6",
")",
"==",
"\"CHMOD \"",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
"... | 权限控制
@param $fd
@param $cmd | [
"权限控制"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L274-L295 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_USER | function cmd_USER($fd, $cmd)
{
if (preg_match("/^([a-z0-9]+)$/", $cmd[1]))
{
$user = $cmd[1];
$this->connections[$fd]['user'] = $user;
$this->users[$user]['fd'] = $fd;
$this->send($fd, "331 User $user OK. Password required");
}
else
... | php | function cmd_USER($fd, $cmd)
{
if (preg_match("/^([a-z0-9]+)$/", $cmd[1]))
{
$user = $cmd[1];
$this->connections[$fd]['user'] = $user;
$this->users[$user]['fd'] = $fd;
$this->send($fd, "331 User $user OK. Password required");
}
else
... | [
"function",
"cmd_USER",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/^([a-z0-9]+)$/\"",
",",
"$",
"cmd",
"[",
"1",
"]",
")",
")",
"{",
"$",
"user",
"=",
"$",
"cmd",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"connect... | 登录用户名
@param $fd
@param $cmd | [
"登录用户名"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L302-L315 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_PASS | function cmd_PASS($fd, $cmd)
{
$user = $this->connections[$fd]['user'];
$pass = $cmd[1];
if (isset($this->users[$user]) and $this->users[$user]['password'] == $pass)
{
if ($this->users[$user]['chroot'])
{
$dir = "/";
}
e... | php | function cmd_PASS($fd, $cmd)
{
$user = $this->connections[$fd]['user'];
$pass = $cmd[1];
if (isset($this->users[$user]) and $this->users[$user]['password'] == $pass)
{
if ($this->users[$user]['chroot'])
{
$dir = "/";
}
e... | [
"function",
"cmd_PASS",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"connections",
"[",
"$",
"fd",
"]",
"[",
"'user'",
"]",
";",
"$",
"pass",
"=",
"$",
"cmd",
"[",
"1",
"]",
";",
"if",
"(",
"isset",
"(",
... | 登录密码
@param $fd
@param $cmd | [
"登录密码"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L322-L345 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_RETR | function cmd_RETR($fd, $cmd)
{
$user = $this->getUser($fd);
$ftpsock = $this->getUserSock($user);
if (($file = $this->getFile($user, $cmd[1])) != false)
{
$this->send($fd, "150 Connecting to client");
if ($fp = fopen($file, "r"))
{
... | php | function cmd_RETR($fd, $cmd)
{
$user = $this->getUser($fd);
$ftpsock = $this->getUserSock($user);
if (($file = $this->getFile($user, $cmd[1])) != false)
{
$this->send($fd, "150 Connecting to client");
if ($fp = fopen($file, "r"))
{
... | [
"function",
"cmd_RETR",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
")",
";",
"$",
"ftpsock",
"=",
"$",
"this",
"->",
"getUserSock",
"(",
"$",
"user",
")",
";",
"if",
"(",
"(",
"$... | 下载文件
@param $fd
@param $cmd | [
"下载文件"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L352-L384 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_TYPE | function cmd_TYPE($fd, $cmd)
{
switch ($cmd[1])
{
case "A":
$type = "ASCII";
break;
case "I":
$type = "8-bit binary";
break;
}
$this->send($fd, "200 TYPE is now " . $type);
} | php | function cmd_TYPE($fd, $cmd)
{
switch ($cmd[1])
{
case "A":
$type = "ASCII";
break;
case "I":
$type = "8-bit binary";
break;
}
$this->send($fd, "200 TYPE is now " . $type);
} | [
"function",
"cmd_TYPE",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"switch",
"(",
"$",
"cmd",
"[",
"1",
"]",
")",
"{",
"case",
"\"A\"",
":",
"$",
"type",
"=",
"\"ASCII\"",
";",
"break",
";",
"case",
"\"I\"",
":",
"$",
"type",
"=",
"\"8-bit binary... | 更改传输类型
@param $fd
@param $cmd | [
"更改传输类型"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L402-L414 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_LIST | function cmd_LIST($fd, $cmd)
{
$user = $this->getUser($fd);
$ftpsock = $this->getUserSock($user);
if (!$ftpsock)
{
$this->send($fd, "501 Connection Error");
return;
}
$this->send($fd, "150 Opening ASCII mode data connection for file list");
... | php | function cmd_LIST($fd, $cmd)
{
$user = $this->getUser($fd);
$ftpsock = $this->getUserSock($user);
if (!$ftpsock)
{
$this->send($fd, "501 Connection Error");
return;
}
$this->send($fd, "150 Opening ASCII mode data connection for file list");
... | [
"function",
"cmd_LIST",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
")",
";",
"$",
"ftpsock",
"=",
"$",
"this",
"->",
"getUserSock",
"(",
"$",
"user",
")",
";",
"if",
"(",
"!",
"$... | 遍历目录
@param $fd
@param $cmd | [
"遍历目录"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L421-L444 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.cmd_PORT | function cmd_PORT($fd, $cmd)
{
$user = $this->getUser($fd);
$port = explode(",", $cmd[1]);
if (count($port) != 6)
{
$this->send($fd, "501 Syntax error in IP address");
}
else
{
if (!$this->isIPAddress($port))
{
... | php | function cmd_PORT($fd, $cmd)
{
$user = $this->getUser($fd);
$port = explode(",", $cmd[1]);
if (count($port) != 6)
{
$this->send($fd, "501 Syntax error in IP address");
}
else
{
if (!$this->isIPAddress($port))
{
... | [
"function",
"cmd_PORT",
"(",
"$",
"fd",
",",
"$",
"cmd",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"fd",
")",
";",
"$",
"port",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"cmd",
"[",
"1",
"]",
")",
";",
"if",
"(",
"co... | 建立数据传输通道
@param $fd
@param $cmd | [
"建立数据传输通道"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L451-L491 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.closeUserSock | function closeUserSock($user)
{
fclose($this->users[$user]['sock']);
$this->users[$user]['sock'] = 0;
return true;
} | php | function closeUserSock($user)
{
fclose($this->users[$user]['sock']);
$this->users[$user]['sock'] = 0;
return true;
} | [
"function",
"closeUserSock",
"(",
"$",
"user",
")",
"{",
"fclose",
"(",
"$",
"this",
"->",
"users",
"[",
"$",
"user",
"]",
"[",
"'sock'",
"]",
")",
";",
"$",
"this",
"->",
"users",
"[",
"$",
"user",
"]",
"[",
"'sock'",
"]",
"=",
"0",
";",
"retu... | 关闭数据传输socket
@param $user
@return bool | [
"关闭数据传输socket"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L537-L542 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.getFileList | function getFileList($rdir, $showHidden = false)
{
$filelist = '';
if ($handle = opendir($rdir))
{
while (false !== ($file = readdir($handle)))
{
if ($file == '.' or $file == '..')
{
continue;
}
... | php | function getFileList($rdir, $showHidden = false)
{
$filelist = '';
if ($handle = opendir($rdir))
{
while (false !== ($file = readdir($handle)))
{
if ($file == '.' or $file == '..')
{
continue;
}
... | [
"function",
"getFileList",
"(",
"$",
"rdir",
",",
"$",
"showHidden",
"=",
"false",
")",
"{",
"$",
"filelist",
"=",
"''",
";",
"if",
"(",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"rdir",
")",
")",
"{",
"while",
"(",
"false",
"!==",
"(",
"$",
"file... | 遍历目录
@param $rdir
@param $showHidden
@return string | [
"遍历目录"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L640-L755 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.setUserDir | function setUserDir($user, $cdir)
{
$old_dir = $this->users[$user]['pwd'];
if ($old_dir == $cdir)
{
return $cdir;
}
if($cdir[0] != '/')
{
$cdir = $old_dir.'/'.$cdir ;
}
$this->debug("CHDIR: $old_dir -> $cdir");... | php | function setUserDir($user, $cdir)
{
$old_dir = $this->users[$user]['pwd'];
if ($old_dir == $cdir)
{
return $cdir;
}
if($cdir[0] != '/')
{
$cdir = $old_dir.'/'.$cdir ;
}
$this->debug("CHDIR: $old_dir -> $cdir");... | [
"function",
"setUserDir",
"(",
"$",
"user",
",",
"$",
"cdir",
")",
"{",
"$",
"old_dir",
"=",
"$",
"this",
"->",
"users",
"[",
"$",
"user",
"]",
"[",
"'pwd'",
"]",
";",
"if",
"(",
"$",
"old_dir",
"==",
"$",
"cdir",
")",
"{",
"return",
"$",
"cdir... | 设置用户当前的路径
@param $user
@param $pwd | [
"设置用户当前的路径"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L762-L785 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.fillDirName | function fillDirName($user, $file)
{
//发过来的文件名不带路径需要补齐
if (substr($file, 0, 1) != "/")
{
$file = $this->getUserDir($user) . "/" . $file;
}
if ($this->users[$user]['chroot'])
{
$file = $this->users[$user]['home'].$file;
}
return ... | php | function fillDirName($user, $file)
{
//发过来的文件名不带路径需要补齐
if (substr($file, 0, 1) != "/")
{
$file = $this->getUserDir($user) . "/" . $file;
}
if ($this->users[$user]['chroot'])
{
$file = $this->users[$user]['home'].$file;
}
return ... | [
"function",
"fillDirName",
"(",
"$",
"user",
",",
"$",
"file",
")",
"{",
"//发过来的文件名不带路径需要补齐",
"if",
"(",
"substr",
"(",
"$",
"file",
",",
"0",
",",
"1",
")",
"!=",
"\"/\"",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getUserDir",
"(",
"$",
"u... | 补齐路径
@param $user
@param $file
@return string | [
"补齐路径"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L793-L805 |
matyhtf/framework | libs/Swoole/Protocol/FtpServer.php | FtpServer.getAbsDir | function getAbsDir($user)
{
if (!$this->users[$user]['chroot'])
{
$rdir = $this->users[$user]['pwd'];
}
else
{
$rdir = $this->users[$user]['home'].$this->users[$user]['pwd'];
}
return $rdir;
} | php | function getAbsDir($user)
{
if (!$this->users[$user]['chroot'])
{
$rdir = $this->users[$user]['pwd'];
}
else
{
$rdir = $this->users[$user]['home'].$this->users[$user]['pwd'];
}
return $rdir;
} | [
"function",
"getAbsDir",
"(",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"users",
"[",
"$",
"user",
"]",
"[",
"'chroot'",
"]",
")",
"{",
"$",
"rdir",
"=",
"$",
"this",
"->",
"users",
"[",
"$",
"user",
"]",
"[",
"'pwd'",
"]",
";... | 获取用户的当前文件系统绝对路径,非chroot路径
@param $user
@return string | [
"获取用户的当前文件系统绝对路径,非chroot路径"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FtpServer.php#L817-L828 |
matyhtf/framework | libs/Swoole/Async/Pool.php | Pool.join | function join($resource)
{
//保存到空闲连接池中
$this->resourcePool[spl_object_hash($resource)] = $resource;
$this->release($resource);
} | php | function join($resource)
{
//保存到空闲连接池中
$this->resourcePool[spl_object_hash($resource)] = $resource;
$this->release($resource);
} | [
"function",
"join",
"(",
"$",
"resource",
")",
"{",
"//保存到空闲连接池中",
"$",
"this",
"->",
"resourcePool",
"[",
"spl_object_hash",
"(",
"$",
"resource",
")",
"]",
"=",
"$",
"resource",
";",
"$",
"this",
"->",
"release",
"(",
"$",
"resource",
")",
";",
"}"
] | 加入到连接池中
@param $resource | [
"加入到连接池中"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Async/Pool.php#L57-L62 |
matyhtf/framework | libs/Swoole/Async/Pool.php | Pool.remove | function remove($resource)
{
$rid = spl_object_hash($resource);
if (!isset($this->resourcePool[$rid]))
{
return false;
}
//从resourcePool中删除
unset($this->resourcePool[$rid]);
$this->resourceNum--;
return true;
} | php | function remove($resource)
{
$rid = spl_object_hash($resource);
if (!isset($this->resourcePool[$rid]))
{
return false;
}
//从resourcePool中删除
unset($this->resourcePool[$rid]);
$this->resourceNum--;
return true;
} | [
"function",
"remove",
"(",
"$",
"resource",
")",
"{",
"$",
"rid",
"=",
"spl_object_hash",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resourcePool",
"[",
"$",
"rid",
"]",
")",
")",
"{",
"return",
"false",
";",
... | 移除资源
@param $resource
@return bool | [
"移除资源"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Async/Pool.php#L95-L106 |
matyhtf/framework | libs/Swoole/Async/Pool.php | Pool.request | public function request(callable $callback)
{
//入队列
$this->taskQueue->enqueue($callback);
//有可用资源
if (count($this->idlePool) > 0)
{
$this->doTask();
}
//没有可用的资源, 创建新的连接
elseif (count($this->resourcePool) < $this->poolSize and $this->resourc... | php | public function request(callable $callback)
{
//入队列
$this->taskQueue->enqueue($callback);
//有可用资源
if (count($this->idlePool) > 0)
{
$this->doTask();
}
//没有可用的资源, 创建新的连接
elseif (count($this->resourcePool) < $this->poolSize and $this->resourc... | [
"public",
"function",
"request",
"(",
"callable",
"$",
"callback",
")",
"{",
"//入队列",
"$",
"this",
"->",
"taskQueue",
"->",
"enqueue",
"(",
"$",
"callback",
")",
";",
"//有可用资源",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"idlePool",
")",
">",
"0",
"... | 请求资源
@param callable $callback
@return bool | [
"请求资源"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Async/Pool.php#L113-L128 |
matyhtf/framework | libs/Swoole/Async/Pool.php | Pool.release | public function release($resource)
{
$this->idlePool->enqueue($resource);
//有任务要做
if (count($this->taskQueue) > 0)
{
$this->doTask();
}
} | php | public function release($resource)
{
$this->idlePool->enqueue($resource);
//有任务要做
if (count($this->taskQueue) > 0)
{
$this->doTask();
}
} | [
"public",
"function",
"release",
"(",
"$",
"resource",
")",
"{",
"$",
"this",
"->",
"idlePool",
"->",
"enqueue",
"(",
"$",
"resource",
")",
";",
"//有任务要做",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"taskQueue",
")",
">",
"0",
")",
"{",
"$",
"this... | 释放资源
@param $resource | [
"释放资源"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Async/Pool.php#L134-L142 |
matyhtf/framework | libs/Swoole/PageCache.php | PageCache.isCached | function isCached()
{
$file = $this->cache_dir . '/' . base64_encode($_SERVER['REQUEST_URI']) . '.html';
if (!file_exists($file))
{
return false;
}
elseif (filemtime($file) + $this->expire < time())
{
return false;
}
else
... | php | function isCached()
{
$file = $this->cache_dir . '/' . base64_encode($_SERVER['REQUEST_URI']) . '.html';
if (!file_exists($file))
{
return false;
}
elseif (filemtime($file) + $this->expire < time())
{
return false;
}
else
... | [
"function",
"isCached",
"(",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"cache_dir",
".",
"'/'",
".",
"base64_encode",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
".",
"'.html'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",... | 检查是否存在有效缓存
@return bool | [
"检查是否存在有效缓存"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/PageCache.php#L52-L67 |
matyhtf/framework | libs/Swoole/Client/TCP.php | TCP.send | function send($data)
{
$length = strlen($data);
$written = 0;
$t1 = microtime(true);
//总超时,for循环中计时
while ($written < $length)
{
$n = socket_send($this->sock, substr($data, $written), $length - $written, null);
//超过总时间
if (microtime... | php | function send($data)
{
$length = strlen($data);
$written = 0;
$t1 = microtime(true);
//总超时,for循环中计时
while ($written < $length)
{
$n = socket_send($this->sock, substr($data, $written), $length - $written, null);
//超过总时间
if (microtime... | [
"function",
"send",
"(",
"$",
"data",
")",
"{",
"$",
"length",
"=",
"strlen",
"(",
"$",
"data",
")",
";",
"$",
"written",
"=",
"0",
";",
"$",
"t1",
"=",
"microtime",
"(",
"true",
")",
";",
"//总超时,for循环中计时",
"while",
"(",
"$",
"written",
"<",
"$",... | 发送数据
@param string $data
@return bool | int | [
"发送数据"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/TCP.php#L21-L51 |
matyhtf/framework | libs/Swoole/Client/TCP.php | TCP.recv | function recv($length = 65535, $waitall = false)
{
$flags = 0;
if ($waitall)
{
$flags = MSG_WAITALL;
}
$ret = socket_recv($this->sock, $data, $length, $flags);
if ($ret === false)
{
$this->set_error();
//重试一次,这里为防止意外,不使用递归循... | php | function recv($length = 65535, $waitall = false)
{
$flags = 0;
if ($waitall)
{
$flags = MSG_WAITALL;
}
$ret = socket_recv($this->sock, $data, $length, $flags);
if ($ret === false)
{
$this->set_error();
//重试一次,这里为防止意外,不使用递归循... | [
"function",
"recv",
"(",
"$",
"length",
"=",
"65535",
",",
"$",
"waitall",
"=",
"false",
")",
"{",
"$",
"flags",
"=",
"0",
";",
"if",
"(",
"$",
"waitall",
")",
"{",
"$",
"flags",
"=",
"MSG_WAITALL",
";",
"}",
"$",
"ret",
"=",
"socket_recv",
"(",
... | 接收数据
@param int $length 接收数据的长度
@param bool $waitall 等待接收到全部数据后再返回,注意这里超过包长度会阻塞住
@return string | bool | [
"接收数据"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/TCP.php#L59-L82 |
matyhtf/framework | libs/Swoole/Client/TCP.php | TCP.connect | function connect($host, $port, $timeout = 0.1, $nonblock = false)
{
//判断超时为0或负数
if (empty($host) or empty($port) or $timeout <= 0)
{
$this->errCode = -10001;
$this->errMsg = "param error";
return false;
}
$this->host = $host;
$this-... | php | function connect($host, $port, $timeout = 0.1, $nonblock = false)
{
//判断超时为0或负数
if (empty($host) or empty($port) or $timeout <= 0)
{
$this->errCode = -10001;
$this->errMsg = "param error";
return false;
}
$this->host = $host;
$this-... | [
"function",
"connect",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"timeout",
"=",
"0.1",
",",
"$",
"nonblock",
"=",
"false",
")",
"{",
"//判断超时为0或负数",
"if",
"(",
"empty",
"(",
"$",
"host",
")",
"or",
"empty",
"(",
"$",
"port",
")",
"or",
"$",
... | 连接到服务器
接受一个浮点型数字作为超时,整数部分作为sec,小数部分*100万作为usec
@param string $host 服务器地址
@param int $port 服务器地址
@param float $timeout 超时默认值,连接,发送,接收都使用此设置
@return bool | [
"连接到服务器",
"接受一个浮点型数字作为超时,整数部分作为sec,小数部分",
"*",
"100万作为usec"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/TCP.php#L93-L141 |
matyhtf/framework | libs/Swoole/Network/SelectTCP.php | SelectTCP.sendAll | function sendAll($client_id = null, $data)
{
foreach ($this->client_sock as $k => $sock)
{
if ($client_id and $k == $client_id) continue;
$this->sendData($sock, $data);
}
} | php | function sendAll($client_id = null, $data)
{
foreach ($this->client_sock as $k => $sock)
{
if ($client_id and $k == $client_id) continue;
$this->sendData($sock, $data);
}
} | [
"function",
"sendAll",
"(",
"$",
"client_id",
"=",
"null",
",",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"client_sock",
"as",
"$",
"k",
"=>",
"$",
"sock",
")",
"{",
"if",
"(",
"$",
"client_id",
"and",
"$",
"k",
"==",
"$",
"client... | 向所有client发送数据
@return unknown_type | [
"向所有client发送数据"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Network/SelectTCP.php#L31-L38 |
matyhtf/framework | libs/Swoole/Controller.php | Controller.trace | protected function trace($title, $value = '')
{
if (is_array($title))
{
$this->traceInfo = array_merge($this->traceInfo, $title);
}
else
{
$this->traceInfo[$title] = $value;
}
} | php | protected function trace($title, $value = '')
{
if (is_array($title))
{
$this->traceInfo = array_merge($this->traceInfo, $title);
}
else
{
$this->traceInfo[$title] = $value;
}
} | [
"protected",
"function",
"trace",
"(",
"$",
"title",
",",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"title",
")",
")",
"{",
"$",
"this",
"->",
"traceInfo",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"traceInfo",
",",
"$",... | 跟踪信息
@param $title
@param $value | [
"跟踪信息"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Controller.php#L47-L57 |
matyhtf/framework | libs/Swoole/Controller.php | Controller.json | function json($data = '', $code = 0, $message = '')
{
$json = array('code' => $code, 'message' => $message, 'data' => $data);
if (!empty($_REQUEST['jsonp']))
{
$this->http->header('Content-type', 'application/x-javascript');
return $_REQUEST['jsonp'] . "(" . json_enco... | php | function json($data = '', $code = 0, $message = '')
{
$json = array('code' => $code, 'message' => $message, 'data' => $data);
if (!empty($_REQUEST['jsonp']))
{
$this->http->header('Content-type', 'application/x-javascript');
return $_REQUEST['jsonp'] . "(" . json_enco... | [
"function",
"json",
"(",
"$",
"data",
"=",
"''",
",",
"$",
"code",
"=",
"0",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"json",
"=",
"array",
"(",
"'code'",
"=>",
"$",
"code",
",",
"'message'",
"=>",
"$",
"message",
",",
"'data'",
"=>",
"$"... | 输出JSON字串
@param string $data
@param int $code
@param string $message
@return string | [
"输出JSON字串",
"@param",
"string",
"$data",
"@param",
"int",
"$code",
"@param",
"string",
"$message"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Controller.php#L88-L101 |
matyhtf/framework | libs/Swoole/Controller.php | Controller.display | function display($_swoole_tpl_file = '')
{
if (empty($_swoole_tpl_file))
{
$_swoole_tpl_file = strtolower($this->swoole->env['mvc']['controller']) . '/' . strtolower($this->swoole->env['mvc']['view']) . '.php';
}
if (!is_file($this->template_dir . $_swoole_tpl_file))
... | php | function display($_swoole_tpl_file = '')
{
if (empty($_swoole_tpl_file))
{
$_swoole_tpl_file = strtolower($this->swoole->env['mvc']['controller']) . '/' . strtolower($this->swoole->env['mvc']['view']) . '.php';
}
if (!is_file($this->template_dir . $_swoole_tpl_file))
... | [
"function",
"display",
"(",
"$",
"_swoole_tpl_file",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"_swoole_tpl_file",
")",
")",
"{",
"$",
"_swoole_tpl_file",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"swoole",
"->",
"env",
"[",
"'mvc'",
"]",
"["... | render template file, then display it.
@param string $_swoole_tpl_file | [
"render",
"template",
"file",
"then",
"display",
"it",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Controller.php#L124-L136 |
matyhtf/framework | libs/Swoole/Controller.php | Controller.showTime | protected function showTime()
{
$runtime = $this->swoole->runtime();
// 显示运行时间
$showTime = '执行时间: ' . $runtime['time'];
// 显示内存占用
$showTime .= ' | 内存占用:' . $runtime['memory'];
return $showTime;
} | php | protected function showTime()
{
$runtime = $this->swoole->runtime();
// 显示运行时间
$showTime = '执行时间: ' . $runtime['time'];
// 显示内存占用
$showTime .= ' | 内存占用:' . $runtime['memory'];
return $showTime;
} | [
"protected",
"function",
"showTime",
"(",
")",
"{",
"$",
"runtime",
"=",
"$",
"this",
"->",
"swoole",
"->",
"runtime",
"(",
")",
";",
"// 显示运行时间",
"$",
"showTime",
"=",
"'执行时间: ' . $runt",
"m",
"[",
"'time']",
";",
"",
"",
"",
"// 显示内存占用",
"$",
"showTi... | 显示运行时间和内存占用
@return string | [
"显示运行时间和内存占用"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Controller.php#L143-L151 |
matyhtf/framework | libs/Swoole/Controller.php | Controller.showTrace | public function showTrace()
{
$_trace = array();
$included_files = get_included_files();
// 系统默认显示信息
if (!empty($this->request->server['SCRIPT_NAME']))
{
$_trace['请求脚本'] = $this->request->server['SCRIPT_NAME'];
}
$_trace['请求方法'] = $this->swoole... | php | public function showTrace()
{
$_trace = array();
$included_files = get_included_files();
// 系统默认显示信息
if (!empty($this->request->server['SCRIPT_NAME']))
{
$_trace['请求脚本'] = $this->request->server['SCRIPT_NAME'];
}
$_trace['请求方法'] = $this->swoole... | [
"public",
"function",
"showTrace",
"(",
")",
"{",
"$",
"_trace",
"=",
"array",
"(",
")",
";",
"$",
"included_files",
"=",
"get_included_files",
"(",
")",
";",
"// 系统默认显示信息",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"request",
"->",
"server",
"[... | 显示跟踪信息
@return string | [
"显示跟踪信息"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Controller.php#L157-L259 |
matyhtf/framework | libs/Swoole/Protocol/HttpServer.php | HttpServer.onReceive | function onReceive($serv, $client_id, $from_id, $data)
{
//检测request data完整性
$ret = $this->checkData($client_id, $data);
switch($ret)
{
//错误的请求
case self::ST_ERROR;
$this->server->close($client_id);
return;
//请求不完整,继... | php | function onReceive($serv, $client_id, $from_id, $data)
{
//检测request data完整性
$ret = $this->checkData($client_id, $data);
switch($ret)
{
//错误的请求
case self::ST_ERROR;
$this->server->close($client_id);
return;
//请求不完整,继... | [
"function",
"onReceive",
"(",
"$",
"serv",
",",
"$",
"client_id",
",",
"$",
"from_id",
",",
"$",
"data",
")",
"{",
"//检测request data完整性",
"$",
"ret",
"=",
"$",
"this",
"->",
"checkData",
"(",
"$",
"client_id",
",",
"$",
"data",
")",
";",
"switch",
"(... | 接收到数据
@param $serv \swoole_server
@param $client_id
@param $from_id
@param $data
@return null | [
"接收到数据"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/HttpServer.php#L211-L268 |
matyhtf/framework | libs/Swoole/Protocol/HttpServer.php | HttpServer.parseRequest | function parseRequest($request)
{
$url_info = parse_url($request->meta['uri']);
$request->meta['path'] = $url_info['path'];
if (isset($url_info['fragment'])) $request->meta['fragment'] = $url_info['fragment'];
if (isset($url_info['query']))
{
parse_str($url_info['... | php | function parseRequest($request)
{
$url_info = parse_url($request->meta['uri']);
$request->meta['path'] = $url_info['path'];
if (isset($url_info['fragment'])) $request->meta['fragment'] = $url_info['fragment'];
if (isset($url_info['query']))
{
parse_str($url_info['... | [
"function",
"parseRequest",
"(",
"$",
"request",
")",
"{",
"$",
"url_info",
"=",
"parse_url",
"(",
"$",
"request",
"->",
"meta",
"[",
"'uri'",
"]",
")",
";",
"$",
"request",
"->",
"meta",
"[",
"'path'",
"]",
"=",
"$",
"url_info",
"[",
"'path'",
"]",
... | 解析请求
@param $request Swoole\Request
@return null | [
"解析请求"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/HttpServer.php#L288-L307 |
matyhtf/framework | libs/Swoole/Protocol/HttpServer.php | HttpServer.response | function response(Swoole\Request $request, Swoole\Response $response)
{
if (!isset($response->head['Date']))
{
$response->head['Date'] = gmdate("D, d M Y H:i:s T");
}
if (!isset($response->head['Connection']))
{
//keepalive
if ($this->keepa... | php | function response(Swoole\Request $request, Swoole\Response $response)
{
if (!isset($response->head['Date']))
{
$response->head['Date'] = gmdate("D, d M Y H:i:s T");
}
if (!isset($response->head['Connection']))
{
//keepalive
if ($this->keepa... | [
"function",
"response",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
",",
"Swoole",
"\\",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"response",
"->",
"head",
"[",
"'Date'",
"]",
")",
")",
"{",
"$",
"response",
"->",... | 发送响应
@param $request Swoole\Request
@param $response Swoole\Response
@return bool | [
"发送响应"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/HttpServer.php#L315-L369 |
matyhtf/framework | libs/Swoole/Protocol/HttpServer.php | HttpServer.httpError | function httpError($code, Swoole\Response $response, $content = '')
{
$response->setHttpStatus($code);
$response->head['Content-Type'] = 'text/html';
$response->body = Swoole\Error::info(Swoole\Response::$HTTP_HEADERS[$code],
"<p>$content</p><hr><address>" . self::SOFTWARE . " at... | php | function httpError($code, Swoole\Response $response, $content = '')
{
$response->setHttpStatus($code);
$response->head['Content-Type'] = 'text/html';
$response->body = Swoole\Error::info(Swoole\Response::$HTTP_HEADERS[$code],
"<p>$content</p><hr><address>" . self::SOFTWARE . " at... | [
"function",
"httpError",
"(",
"$",
"code",
",",
"Swoole",
"\\",
"Response",
"$",
"response",
",",
"$",
"content",
"=",
"''",
")",
"{",
"$",
"response",
"->",
"setHttpStatus",
"(",
"$",
"code",
")",
";",
"$",
"response",
"->",
"head",
"[",
"'Content-Typ... | 发生了http错误
@param $code
@param Swoole\Response $response
@param string $content | [
"发生了http错误"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/HttpServer.php#L377-L384 |
matyhtf/framework | libs/Swoole/Protocol/HttpServer.php | HttpServer.onErrorShutDown | function onErrorShutDown()
{
$error = error_get_last();
if (!isset($error['type'])) return;
switch ($error['type'])
{
case E_ERROR :
case E_PARSE :
case E_USER_ERROR:
case E_CORE_ERROR :
case E_COMPILE_ERROR :
... | php | function onErrorShutDown()
{
$error = error_get_last();
if (!isset($error['type'])) return;
switch ($error['type'])
{
case E_ERROR :
case E_PARSE :
case E_USER_ERROR:
case E_CORE_ERROR :
case E_COMPILE_ERROR :
... | [
"function",
"onErrorShutDown",
"(",
")",
"{",
"$",
"error",
"=",
"error_get_last",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"error",
"[",
"'type'",
"]",
")",
")",
"return",
";",
"switch",
"(",
"$",
"error",
"[",
"'type'",
"]",
")",
"{",
... | 捕获register_shutdown_function错误 | [
"捕获register_shutdown_function错误"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/HttpServer.php#L389-L405 |
matyhtf/framework | libs/Swoole/Protocol/HttpServer.php | HttpServer.onErrorHandle | function onErrorHandle($errno, $errstr, $errfile, $errline)
{
$error = array(
'message' => $errstr,
'file' => $errfile,
'line' => $errline,
);
$this->errorResponse($error);
} | php | function onErrorHandle($errno, $errstr, $errfile, $errline)
{
$error = array(
'message' => $errstr,
'file' => $errfile,
'line' => $errline,
);
$this->errorResponse($error);
} | [
"function",
"onErrorHandle",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"$",
"error",
"=",
"array",
"(",
"'message'",
"=>",
"$",
"errstr",
",",
"'file'",
"=>",
"$",
"errfile",
",",
"'line'",
"=>",
"$",
... | 捕获set_error_handle错误 | [
"捕获set_error_handle错误"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/HttpServer.php#L410-L418 |
matyhtf/framework | libs/Swoole/Protocol/HttpServer.php | HttpServer.errorResponse | private function errorResponse($error)
{
$errorMsg = "{$error['message']} ({$error['file']}:{$error['line']})";
$message = Swoole\Error::info(self::SOFTWARE." Application Error", $errorMsg);
if (empty($this->currentResponse))
{
$this->currentResponse = new Swoole\Response... | php | private function errorResponse($error)
{
$errorMsg = "{$error['message']} ({$error['file']}:{$error['line']})";
$message = Swoole\Error::info(self::SOFTWARE." Application Error", $errorMsg);
if (empty($this->currentResponse))
{
$this->currentResponse = new Swoole\Response... | [
"private",
"function",
"errorResponse",
"(",
"$",
"error",
")",
"{",
"$",
"errorMsg",
"=",
"\"{$error['message']} ({$error['file']}:{$error['line']})\"",
";",
"$",
"message",
"=",
"Swoole",
"\\",
"Error",
"::",
"info",
"(",
"self",
"::",
"SOFTWARE",
".",
"\" Appli... | 错误显示
@param $error | [
"错误显示"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/HttpServer.php#L424-L436 |
matyhtf/framework | libs/Swoole/Protocol/HttpServer.php | HttpServer.onRequest | function onRequest(Swoole\Request $request)
{
$response = new Swoole\Response;
$this->currentResponse = $response;
\Swoole::$php->request = $request;
\Swoole::$php->response = $response;
//请求路径
if ($request->meta['path'][strlen($request->meta['path']) - 1] == '/')
... | php | function onRequest(Swoole\Request $request)
{
$response = new Swoole\Response;
$this->currentResponse = $response;
\Swoole::$php->request = $request;
\Swoole::$php->response = $response;
//请求路径
if ($request->meta['path'][strlen($request->meta['path']) - 1] == '/')
... | [
"function",
"onRequest",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"new",
"Swoole",
"\\",
"Response",
";",
"$",
"this",
"->",
"currentResponse",
"=",
"$",
"response",
";",
"\\",
"Swoole",
"::",
"$",
"php",
"->",
"r... | 处理请求
@param $request
@return Swoole\Response | [
"处理请求"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/HttpServer.php#L443-L470 |
matyhtf/framework | libs/Swoole/Protocol/HttpServer.php | HttpServer.doStaticRequest | function doStaticRequest(Swoole\Request $request, Swoole\Response $response)
{
$path = explode('/', trim($request->meta['path'], '/'));
//扩展名
$request->ext_name = $ext_name = Swoole\Upload::getFileExt($request->meta['path']);
/* 检测是否拒绝访问 */
if (isset($this->deny_dir[$path[0]]... | php | function doStaticRequest(Swoole\Request $request, Swoole\Response $response)
{
$path = explode('/', trim($request->meta['path'], '/'));
//扩展名
$request->ext_name = $ext_name = Swoole\Upload::getFileExt($request->meta['path']);
/* 检测是否拒绝访问 */
if (isset($this->deny_dir[$path[0]]... | [
"function",
"doStaticRequest",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
",",
"Swoole",
"\\",
"Response",
"$",
"response",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'/'",
",",
"trim",
"(",
"$",
"request",
"->",
"meta",
"[",
"'path'",
"]",
",",... | 过滤请求,阻止静止访问的目录,处理静态文件
@param Swoole\Request $request
@param Swoole\Response $response
@return bool | [
"过滤请求,阻止静止访问的目录,处理静态文件"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/HttpServer.php#L478-L495 |
matyhtf/framework | libs/Swoole/Protocol/HttpServer.php | HttpServer.processStatic | function processStatic(Swoole\Request $request, Swoole\Response $response)
{
$path = $this->document_root . '/' . $request->meta['path'];
if (is_file($path))
{
$read_file = true;
if ($this->expire)
{
$expire = intval($this->config['server']... | php | function processStatic(Swoole\Request $request, Swoole\Response $response)
{
$path = $this->document_root . '/' . $request->meta['path'];
if (is_file($path))
{
$read_file = true;
if ($this->expire)
{
$expire = intval($this->config['server']... | [
"function",
"processStatic",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
",",
"Swoole",
"\\",
"Response",
"$",
"response",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"document_root",
".",
"'/'",
".",
"$",
"request",
"->",
"meta",
"[",
"'path'",
... | 处理静态请求
@param Swoole\Request $request
@param Swoole\Response $response
@return bool | [
"处理静态请求"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/HttpServer.php#L503-L544 |
matyhtf/framework | libs/Swoole/Protocol/HttpServer.php | HttpServer.processDynamic | function processDynamic(Swoole\Request $request, Swoole\Response $response)
{
$path = $this->document_root . '/' . $request->meta['path'];
if (is_file($path))
{
$response->head['Content-Type'] = 'text/html';
ob_start();
try
{
in... | php | function processDynamic(Swoole\Request $request, Swoole\Response $response)
{
$path = $this->document_root . '/' . $request->meta['path'];
if (is_file($path))
{
$response->head['Content-Type'] = 'text/html';
ob_start();
try
{
in... | [
"function",
"processDynamic",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
",",
"Swoole",
"\\",
"Response",
"$",
"response",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"document_root",
".",
"'/'",
".",
"$",
"request",
"->",
"meta",
"[",
"'path'",
... | 处理动态请求
@param Swoole\Request $request
@param Swoole\Response $response | [
"处理动态请求"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/HttpServer.php#L551-L574 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.doHandshake | public function doHandshake(Swoole\Request $request, Swoole\Response $response)
{
if (!isset($request->header['Sec-WebSocket-Key']))
{
$this->log('Bad protocol implementation: it is not RFC6455.');
return false;
}
$key = $request->header['Sec-WebSocket-Key'];... | php | public function doHandshake(Swoole\Request $request, Swoole\Response $response)
{
if (!isset($request->header['Sec-WebSocket-Key']))
{
$this->log('Bad protocol implementation: it is not RFC6455.');
return false;
}
$key = $request->header['Sec-WebSocket-Key'];... | [
"public",
"function",
"doHandshake",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
",",
"Swoole",
"\\",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"request",
"->",
"header",
"[",
"'Sec-WebSocket-Key'",
"]",
")",
")",
"{",... | Do the handshake.
@param Swoole\Request $request
@param Swoole\Response $response
@throws \Exception
@return bool | [
"Do",
"the",
"handshake",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L51-L78 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.cleanConnection | function cleanConnection()
{
$now = time();
foreach($this->connections as $client_id => $conn)
{
if($conn['time'] < $now - $this->heart_time)
{
$this->log("connection[$client_id] timeout.", 'CLOSE');
$this->close($client_id);
... | php | function cleanConnection()
{
$now = time();
foreach($this->connections as $client_id => $conn)
{
if($conn['time'] < $now - $this->heart_time)
{
$this->log("connection[$client_id] timeout.", 'CLOSE');
$this->close($client_id);
... | [
"function",
"cleanConnection",
"(",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"connections",
"as",
"$",
"client_id",
"=>",
"$",
"conn",
")",
"{",
"if",
"(",
"$",
"conn",
"[",
"'time'",
"]",
"<",
"$",
"no... | clean all connection | [
"clean",
"all",
"connection"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L88-L100 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.onWebSocketRequest | function onWebSocketRequest(Swoole\Request $request)
{
$response = $this->currentResponse = new Swoole\Response();
$this->doHandshake($request, $response);
return $response;
} | php | function onWebSocketRequest(Swoole\Request $request)
{
$response = $this->currentResponse = new Swoole\Response();
$this->doHandshake($request, $response);
return $response;
} | [
"function",
"onWebSocketRequest",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"currentResponse",
"=",
"new",
"Swoole",
"\\",
"Response",
"(",
")",
";",
"$",
"this",
"->",
"doHandshake",
"(",
"$",
"re... | Produce response for WebSocket request.
@param Swoole\Request $request
@return Swoole\Response | [
"Produce",
"response",
"for",
"WebSocket",
"request",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L164-L169 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.onRequest | function onRequest(Swoole\Request $request)
{
return $request->isWebSocket() ? $this->onWebSocketRequest($request) : $this->onHttpRequest($request);
} | php | function onRequest(Swoole\Request $request)
{
return $request->isWebSocket() ? $this->onWebSocketRequest($request) : $this->onHttpRequest($request);
} | [
"function",
"onRequest",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
")",
"{",
"return",
"$",
"request",
"->",
"isWebSocket",
"(",
")",
"?",
"$",
"this",
"->",
"onWebSocketRequest",
"(",
"$",
"request",
")",
":",
"$",
"this",
"->",
"onHttpRequest",
"... | Request come
@param Swoole\Request $request
@return Swoole\Response | [
"Request",
"come"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L176-L179 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.afterResponse | function afterResponse(Swoole\Request $request, Swoole\Response $response)
{
if ($request->isWebSocket())
{
$conn = array('header' => $request->header, 'time' => time());
$this->connections[$request->fd] = $conn;
if (count($this->connections) > $this->max_connect... | php | function afterResponse(Swoole\Request $request, Swoole\Response $response)
{
if ($request->isWebSocket())
{
$conn = array('header' => $request->header, 'time' => time());
$this->connections[$request->fd] = $conn;
if (count($this->connections) > $this->max_connect... | [
"function",
"afterResponse",
"(",
"Swoole",
"\\",
"Request",
"$",
"request",
",",
"Swoole",
"\\",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"isWebSocket",
"(",
")",
")",
"{",
"$",
"conn",
"=",
"array",
"(",
"'header'",
"=>... | Clean and fire onWsConnect().
@param Swoole\Request $request
@param Swoole\Response $response | [
"Clean",
"and",
"fire",
"onWsConnect",
"()",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L186-L201 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.onReceive | public function onReceive($server, $fd, $from_id, $data)
{
//$this->log("Connection[{$fd}] received ".strlen($data)." bytes.");
//未连接
if (!isset($this->connections[$fd]))
{
return parent::onReceive($server, $fd, $from_id, $data);
}
while (strlen($data) > ... | php | public function onReceive($server, $fd, $from_id, $data)
{
//$this->log("Connection[{$fd}] received ".strlen($data)." bytes.");
//未连接
if (!isset($this->connections[$fd]))
{
return parent::onReceive($server, $fd, $from_id, $data);
}
while (strlen($data) > ... | [
"public",
"function",
"onReceive",
"(",
"$",
"server",
",",
"$",
"fd",
",",
"$",
"from_id",
",",
"$",
"data",
")",
"{",
"//$this->log(\"Connection[{$fd}] received \".strlen($data).\" bytes.\");",
"//未连接",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"connect... | Read a frame.
@access public
@throw \Exception | [
"Read",
"a",
"frame",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L209-L267 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.parseFrame | function parseFrame(&$buffer)
{
//$this->log("PaserFrame. BufferLen=".strlen($buffer));
//websocket
$ws = array();
$ws['finish'] = false;
$data_offset = 0;
//fin:1 rsv1:1 rsv2:1 rsv3:1 opcode:4
$handle = ord($buffer[$data_offset]);
$ws['fin']... | php | function parseFrame(&$buffer)
{
//$this->log("PaserFrame. BufferLen=".strlen($buffer));
//websocket
$ws = array();
$ws['finish'] = false;
$data_offset = 0;
//fin:1 rsv1:1 rsv2:1 rsv3:1 opcode:4
$handle = ord($buffer[$data_offset]);
$ws['fin']... | [
"function",
"parseFrame",
"(",
"&",
"$",
"buffer",
")",
"{",
"//$this->log(\"PaserFrame. BufferLen=\".strlen($buffer));",
"//websocket",
"$",
"ws",
"=",
"array",
"(",
")",
";",
"$",
"ws",
"[",
"'finish'",
"]",
"=",
"false",
";",
"$",
"data_offset",
"=",
"0",
... | 解析数据帧
返回false表示解析失败,需要关闭此连接
@param $buffer
@return array|bool | [
"解析数据帧",
"返回false表示解析失败,需要关闭此连接"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L275-L361 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.newFrame | public function newFrame($message, $opcode = self::OPCODE_TEXT_FRAME, $end = true)
{
$fin = true === $end ? 0x1 : 0x0;
$rsv1 = 0x0;
$rsv2 = 0x0;
$rsv3 = 0x0;
$length = strlen($message);
$out = chr(($fin << 7) | ($rsv1 << 6) | ($rsv2 << 5) | ($rsv3 << 4) | $opcode);
... | php | public function newFrame($message, $opcode = self::OPCODE_TEXT_FRAME, $end = true)
{
$fin = true === $end ? 0x1 : 0x0;
$rsv1 = 0x0;
$rsv2 = 0x0;
$rsv3 = 0x0;
$length = strlen($message);
$out = chr(($fin << 7) | ($rsv1 << 6) | ($rsv2 << 5) | ($rsv3 << 4) | $opcode);
... | [
"public",
"function",
"newFrame",
"(",
"$",
"message",
",",
"$",
"opcode",
"=",
"self",
"::",
"OPCODE_TEXT_FRAME",
",",
"$",
"end",
"=",
"true",
")",
"{",
"$",
"fin",
"=",
"true",
"===",
"$",
"end",
"?",
"0x1",
":",
"0x0",
";",
"$",
"rsv1",
"=",
... | Write a frame.
@access public
@param string $message Message.
@param int $opcode Opcode.
@param bool $end
@return int | [
"Write",
"a",
"frame",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L387-L410 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.send | public function send($client_id, $message, $opcode = self::OPCODE_TEXT_FRAME, $end = true)
{
if ((self::OPCODE_TEXT_FRAME === $opcode or self::OPCODE_CONTINUATION_FRAME === $opcode) and false === (bool) preg_match('//u', $message))
{
$this->log('Message [%s] is not in UTF-8, cannot send... | php | public function send($client_id, $message, $opcode = self::OPCODE_TEXT_FRAME, $end = true)
{
if ((self::OPCODE_TEXT_FRAME === $opcode or self::OPCODE_CONTINUATION_FRAME === $opcode) and false === (bool) preg_match('//u', $message))
{
$this->log('Message [%s] is not in UTF-8, cannot send... | [
"public",
"function",
"send",
"(",
"$",
"client_id",
",",
"$",
"message",
",",
"$",
"opcode",
"=",
"self",
"::",
"OPCODE_TEXT_FRAME",
",",
"$",
"end",
"=",
"true",
")",
"{",
"if",
"(",
"(",
"self",
"::",
"OPCODE_TEXT_FRAME",
"===",
"$",
"opcode",
"or",... | Send a message.
@access public
@param int $client_id
@param string $message Message.
@param int $opcode Opcode.
@param bool $end Whether it is the last frame of the message.
@return bool | [
"Send",
"a",
"message",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L422-L434 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.opcodeSwitch | function opcodeSwitch($client_id, &$ws)
{
$this->log("[$client_id] opcode={$ws['opcode']}");
switch($ws['opcode'])
{
//data frame
case self::OPCODE_BINARY_FRAME:
case self::OPCODE_TEXT_FRAME:
if (0x1 === $ws['fin'])
{
... | php | function opcodeSwitch($client_id, &$ws)
{
$this->log("[$client_id] opcode={$ws['opcode']}");
switch($ws['opcode'])
{
//data frame
case self::OPCODE_BINARY_FRAME:
case self::OPCODE_TEXT_FRAME:
if (0x1 === $ws['fin'])
{
... | [
"function",
"opcodeSwitch",
"(",
"$",
"client_id",
",",
"&",
"$",
"ws",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"[$client_id] opcode={$ws['opcode']}\"",
")",
";",
"switch",
"(",
"$",
"ws",
"[",
"'opcode'",
"]",
")",
"{",
"//data frame",
"case",
"self",
... | opcode switch
@param $client_id
@param $ws | [
"opcode",
"switch"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L441-L521 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.close | public function close($fd, $code = self::CLOSE_NORMAL, $reason = '')
{
$this->send($fd, pack('n', $code).$reason, self::OPCODE_CONNECTION_CLOSE);
$this->log("server close connection[$fd]. reason: $reason, close_code = $code");
return $this->server->close($fd);
} | php | public function close($fd, $code = self::CLOSE_NORMAL, $reason = '')
{
$this->send($fd, pack('n', $code).$reason, self::OPCODE_CONNECTION_CLOSE);
$this->log("server close connection[$fd]. reason: $reason, close_code = $code");
return $this->server->close($fd);
} | [
"public",
"function",
"close",
"(",
"$",
"fd",
",",
"$",
"code",
"=",
"self",
"::",
"CLOSE_NORMAL",
",",
"$",
"reason",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"send",
"(",
"$",
"fd",
",",
"pack",
"(",
"'n'",
",",
"$",
"code",
")",
".",
"$",
... | Close a connection.
@access public
@param int $fd
@param int $code
@param string $reason Reason.
@return bool | [
"Close",
"a",
"connection",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L533-L538 |
matyhtf/framework | libs/Swoole/Protocol/WebSocket.php | WebSocket.cleanBuffer | function cleanBuffer($fd)
{
unset($this->frame_list[$fd], $this->connections[$fd]);
parent::cleanBuffer($fd);
} | php | function cleanBuffer($fd)
{
unset($this->frame_list[$fd], $this->connections[$fd]);
parent::cleanBuffer($fd);
} | [
"function",
"cleanBuffer",
"(",
"$",
"fd",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"frame_list",
"[",
"$",
"fd",
"]",
",",
"$",
"this",
"->",
"connections",
"[",
"$",
"fd",
"]",
")",
";",
"parent",
"::",
"cleanBuffer",
"(",
"$",
"fd",
")",
";"... | 清理连接缓存区
@param $fd | [
"清理连接缓存区"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/WebSocket.php#L544-L548 |
matyhtf/framework | libs/Swoole/Template.php | Template.pagecache | function pagecache()
{
$pagecache = new PageCache($this->cache_life);
if ($pagecache->isCached())
{
$pagecache->load();
}
else
{
return false;
}
return true;
} | php | function pagecache()
{
$pagecache = new PageCache($this->cache_life);
if ($pagecache->isCached())
{
$pagecache->load();
}
else
{
return false;
}
return true;
} | [
"function",
"pagecache",
"(",
")",
"{",
"$",
"pagecache",
"=",
"new",
"PageCache",
"(",
"$",
"this",
"->",
"cache_life",
")",
";",
"if",
"(",
"$",
"pagecache",
"->",
"isCached",
"(",
")",
")",
"{",
"$",
"pagecache",
"->",
"load",
"(",
")",
";",
"}"... | 缓存当前页面
@return bool | [
"缓存当前页面"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Template.php#L48-L60 |
matyhtf/framework | libs/Swoole/Template.php | Template.outhtml | function outhtml($template, $filename, $path = '')
{
if ($path == '')
{
$path = dirname($filename);
$filename = basename($filename);
}
if (!is_dir($path))
{
mkdir($path, 0777, true);
}
$content = $this->fetch($template);
file_put_contents($path . '/' . $filename, $content);
return true;
} | php | function outhtml($template, $filename, $path = '')
{
if ($path == '')
{
$path = dirname($filename);
$filename = basename($filename);
}
if (!is_dir($path))
{
mkdir($path, 0777, true);
}
$content = $this->fetch($template);
file_put_contents($path . '/' . $filename, $content);
return true;
} | [
"function",
"outhtml",
"(",
"$",
"template",
",",
"$",
"filename",
",",
"$",
"path",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"path",
"==",
"''",
")",
"{",
"$",
"path",
"=",
"dirname",
"(",
"$",
"filename",
")",
";",
"$",
"filename",
"=",
"basename",... | 生成静态页面
@param $template
@param $filename
@return bool | [
"生成静态页面"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Template.php#L101-L115 |
matyhtf/framework | libs/Swoole/Http/WebSocketParser.php | WebSocketParser.pop | function pop()
{
//当前有等待的frame
if ($this->frame)
{
if (strlen($this->buffer) >= $this->frame->length)
{
//分包
$this->frame->data = substr($this->buffer, 0, $this->frame->length);
self::unMask($this->frame);
... | php | function pop()
{
//当前有等待的frame
if ($this->frame)
{
if (strlen($this->buffer) >= $this->frame->length)
{
//分包
$this->frame->data = substr($this->buffer, 0, $this->frame->length);
self::unMask($this->frame);
... | [
"function",
"pop",
"(",
")",
"{",
"//当前有等待的frame",
"if",
"(",
"$",
"this",
"->",
"frame",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"buffer",
")",
">=",
"$",
"this",
"->",
"frame",
"->",
"length",
")",
"{",
"//分包",
"$",
"this",
"->",... | 弹出frame
@return bool|WebSocketFrame
@throws Swoole\Http\WebSocketException | [
"弹出frame"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Http/WebSocketParser.php#L32-L138 |
matyhtf/framework | libs/Swoole/DOM/Tree.php | Tree.clear | function clear()
{
foreach ($this->nodes as $n) {$n->clear(); $n = null;}
// This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear.
if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;}
if ... | php | function clear()
{
foreach ($this->nodes as $n) {$n->clear(); $n = null;}
// This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear.
if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;}
if ... | [
"function",
"clear",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"n",
")",
"{",
"$",
"n",
"->",
"clear",
"(",
")",
";",
"$",
"n",
"=",
"null",
";",
"}",
"// This add next line is documented in the sourceforge repository. 2977248 as ... | clean up memory due to php5 circular references memory leak... | [
"clean",
"up",
"memory",
"due",
"to",
"php5",
"circular",
"references",
"memory",
"leak",
"..."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/DOM/Tree.php#L251-L260 |
matyhtf/framework | libs/Swoole/DOM/Tree.php | Tree.prepare | protected function prepare($str, $lowercase=true, $stripRN=true, $defaultBRText=self::DEFAULT_BR_TEXT, $defaultSpanText=self::DEFAULT_SPAN_TEXT)
{
$this->clear();
// set the length of content before we do anything to it.
$this->size = strlen($str);
// Save the original size of the html that we got in. It mig... | php | protected function prepare($str, $lowercase=true, $stripRN=true, $defaultBRText=self::DEFAULT_BR_TEXT, $defaultSpanText=self::DEFAULT_SPAN_TEXT)
{
$this->clear();
// set the length of content before we do anything to it.
$this->size = strlen($str);
// Save the original size of the html that we got in. It mig... | [
"protected",
"function",
"prepare",
"(",
"$",
"str",
",",
"$",
"lowercase",
"=",
"true",
",",
"$",
"stripRN",
"=",
"true",
",",
"$",
"defaultBRText",
"=",
"self",
"::",
"DEFAULT_BR_TEXT",
",",
"$",
"defaultSpanText",
"=",
"self",
"::",
"DEFAULT_SPAN_TEXT",
... | prepare HTML data and init everything | [
"prepare",
"HTML",
"data",
"and",
"init",
"everything"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/DOM/Tree.php#L268-L300 |
matyhtf/framework | libs/Swoole/DOM/Tree.php | Tree.parse | protected function parse()
{
if (($s = $this->copy_until_char('<'))==='')
{
return $this->read_tag();
}
// text
$node = new Node($this);
++$this->cursor;
$node->_[self::HDOM_INFO_TEXT] = $s;
$this->link_nodes($node, false);
return true;
} | php | protected function parse()
{
if (($s = $this->copy_until_char('<'))==='')
{
return $this->read_tag();
}
// text
$node = new Node($this);
++$this->cursor;
$node->_[self::HDOM_INFO_TEXT] = $s;
$this->link_nodes($node, false);
return true;
} | [
"protected",
"function",
"parse",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"s",
"=",
"$",
"this",
"->",
"copy_until_char",
"(",
"'<'",
")",
")",
"===",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"read_tag",
"(",
")",
";",
"}",
"// text",
"$",
"node"... | parse html content | [
"parse",
"html",
"content"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/DOM/Tree.php#L303-L316 |
matyhtf/framework | libs/Swoole/DOM/Tree.php | Tree.link_nodes | protected function link_nodes(&$node, $is_child)
{
$node->parent = $this->parent;
$this->parent->nodes[] = $node;
if ($is_child)
{
$this->parent->children[] = $node;
}
} | php | protected function link_nodes(&$node, $is_child)
{
$node->parent = $this->parent;
$this->parent->nodes[] = $node;
if ($is_child)
{
$this->parent->children[] = $node;
}
} | [
"protected",
"function",
"link_nodes",
"(",
"&",
"$",
"node",
",",
"$",
"is_child",
")",
"{",
"$",
"node",
"->",
"parent",
"=",
"$",
"this",
"->",
"parent",
";",
"$",
"this",
"->",
"parent",
"->",
"nodes",
"[",
"]",
"=",
"$",
"node",
";",
"if",
"... | link node's parent | [
"link",
"node",
"s",
"parent"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/DOM/Tree.php#L659-L667 |
matyhtf/framework | libs/Swoole/DOM/Tree.php | Tree.restore_noise | function restore_noise($text)
{
global $debug_object;
if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
while (($pos=strpos($text, '___noise___'))!==false)
{
// Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us..... | php | function restore_noise($text)
{
global $debug_object;
if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
while (($pos=strpos($text, '___noise___'))!==false)
{
// Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us..... | [
"function",
"restore_noise",
"(",
"$",
"text",
")",
"{",
"global",
"$",
"debug_object",
";",
"if",
"(",
"is_object",
"(",
"$",
"debug_object",
")",
")",
"{",
"$",
"debug_object",
"->",
"debug_log_entry",
"(",
"1",
")",
";",
"}",
"while",
"(",
"(",
"$",... | restore noise to html content | [
"restore",
"noise",
"to",
"html",
"content"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/DOM/Tree.php#L779-L809 |
matyhtf/framework | libs/Swoole/DOM/Tree.php | Tree.search_noise | function search_noise($text)
{
global $debug_object;
if (is_object($debug_object)) {
$debug_object->debug_log_entry(1);
}
foreach ($this->noise as $noiseElement) {
if (strpos($noiseElement, $text) !== false) {
return $noiseElement;
}
... | php | function search_noise($text)
{
global $debug_object;
if (is_object($debug_object)) {
$debug_object->debug_log_entry(1);
}
foreach ($this->noise as $noiseElement) {
if (strpos($noiseElement, $text) !== false) {
return $noiseElement;
}
... | [
"function",
"search_noise",
"(",
"$",
"text",
")",
"{",
"global",
"$",
"debug_object",
";",
"if",
"(",
"is_object",
"(",
"$",
"debug_object",
")",
")",
"{",
"$",
"debug_object",
"->",
"debug_log_entry",
"(",
"1",
")",
";",
"}",
"foreach",
"(",
"$",
"th... | Sometimes we NEED one of the noise elements. | [
"Sometimes",
"we",
"NEED",
"one",
"of",
"the",
"noise",
"elements",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/DOM/Tree.php#L812-L825 |
matyhtf/framework | libs/Swoole/DOM/Tree.php | Tree.buildFromFile | static function buildFromFile($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = self::DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=self::DEFAULT_BR_TEXT, $defaultSpanText=self::DEFAULT_SPAN_TEXT)
{
// We DO force th... | php | static function buildFromFile($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = self::DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=self::DEFAULT_BR_TEXT, $defaultSpanText=self::DEFAULT_SPAN_TEXT)
{
// We DO force th... | [
"static",
"function",
"buildFromFile",
"(",
"$",
"url",
",",
"$",
"use_include_path",
"=",
"false",
",",
"$",
"context",
"=",
"null",
",",
"$",
"offset",
"=",
"-",
"1",
",",
"$",
"maxLen",
"=",
"-",
"1",
",",
"$",
"lowercase",
"=",
"true",
",",
"$"... | helper functions
-----------------------------------------------------------------------------
get html dom from file
$maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
@param $url
@param bool $use_include_path
@param null $context
@param $offset
@param $maxLen
@param bool $lowercase
@param b... | [
"helper",
"functions",
"-----------------------------------------------------------------------------",
"get",
"html",
"dom",
"from",
"file",
"$maxlen",
"is",
"defined",
"in",
"the",
"code",
"as",
"PHP_STREAM_COPY_ALL",
"which",
"is",
"defined",
"as",
"-",
"1",
"."
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/DOM/Tree.php#L921-L936 |
matyhtf/framework | libs/Swoole/DOM/Tree.php | Tree.buildFromString | static function buildFromString($str, $lowercase=true, $forceTagsClosed=true, $target_charset = self::DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=self::DEFAULT_BR_TEXT, $defaultSpanText=self::DEFAULT_SPAN_TEXT)
{
$dom = new Tree(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defau... | php | static function buildFromString($str, $lowercase=true, $forceTagsClosed=true, $target_charset = self::DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=self::DEFAULT_BR_TEXT, $defaultSpanText=self::DEFAULT_SPAN_TEXT)
{
$dom = new Tree(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defau... | [
"static",
"function",
"buildFromString",
"(",
"$",
"str",
",",
"$",
"lowercase",
"=",
"true",
",",
"$",
"forceTagsClosed",
"=",
"true",
",",
"$",
"target_charset",
"=",
"self",
"::",
"DEFAULT_TARGET_CHARSET",
",",
"$",
"stripRN",
"=",
"true",
",",
"$",
"de... | get html dom from string
@param $str
@param bool $lowercase
@param bool $forceTagsClosed
@param $target_charset
@param bool $stripRN
@param $defaultBRText
@param $defaultSpanText
@return bool|Tree | [
"get",
"html",
"dom",
"from",
"string"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/DOM/Tree.php#L949-L959 |
matyhtf/framework | libs/Swoole/DOM/Tree.php | Tree.findAndRemove | function findAndRemove($selector, $idx = null ,$excludes = array())
{
if (empty($excludes)) return $this->find($selector,$idx);
foreach ($excludes as $exclude) {
foreach ($this->find($exclude) as $node) {
$node->outertext = '';
}
}
$this->load... | php | function findAndRemove($selector, $idx = null ,$excludes = array())
{
if (empty($excludes)) return $this->find($selector,$idx);
foreach ($excludes as $exclude) {
foreach ($this->find($exclude) as $node) {
$node->outertext = '';
}
}
$this->load... | [
"function",
"findAndRemove",
"(",
"$",
"selector",
",",
"$",
"idx",
"=",
"null",
",",
"$",
"excludes",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"excludes",
")",
")",
"return",
"$",
"this",
"->",
"find",
"(",
"$",
"selector",
... | find and remove dom node by css selector
@param string $selector
@param string $idx
@param array $excludes
@return array | [
"find",
"and",
"remove",
"dom",
"node",
"by",
"css",
"selector"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/DOM/Tree.php#L979-L990 |
matyhtf/framework | libs/Swoole/Coroutine/Component/Base.php | MinHeap.compare | public function compare($array1, $array2)
{
$p1 = $array1['priority'];
$p2 = $array2['priority'];
if ($p1 === $p2) return 0;
return $p1 > $p2 ? -1 : 1;
} | php | public function compare($array1, $array2)
{
$p1 = $array1['priority'];
$p2 = $array2['priority'];
if ($p1 === $p2) return 0;
return $p1 > $p2 ? -1 : 1;
} | [
"public",
"function",
"compare",
"(",
"$",
"array1",
",",
"$",
"array2",
")",
"{",
"$",
"p1",
"=",
"$",
"array1",
"[",
"'priority'",
"]",
";",
"$",
"p2",
"=",
"$",
"array2",
"[",
"'priority'",
"]",
";",
"if",
"(",
"$",
"p1",
"===",
"$",
"p2",
"... | /*
key => obj | [
"/",
"*",
"key",
"=",
">",
"obj"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Coroutine/Component/Base.php#L113-L119 |
matyhtf/framework | libs/Swoole/ArrayObject.php | ArrayObject.remove | function remove($value)
{
$key = $this->search($value);
if ($key)
{
unset($this->array[$key]);
}
return $this;
} | php | function remove($value)
{
$key = $this->search($value);
if ($key)
{
unset($this->array[$key]);
}
return $this;
} | [
"function",
"remove",
"(",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"search",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"r... | 移除元素
@param $value
@return ArrayObject | [
"移除元素"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/ArrayObject.php#L272-L281 |
matyhtf/framework | libs/Swoole/ArrayObject.php | ArrayObject.column | function column($column_key, $index = null)
{
if ($index)
{
return array_column($this->array, $column_key, $index);
}
else
{
return new ArrayObject(array_column($this->array, $column_key));
}
} | php | function column($column_key, $index = null)
{
if ($index)
{
return array_column($this->array, $column_key, $index);
}
else
{
return new ArrayObject(array_column($this->array, $column_key));
}
} | [
"function",
"column",
"(",
"$",
"column_key",
",",
"$",
"index",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"index",
")",
"{",
"return",
"array_column",
"(",
"$",
"this",
"->",
"array",
",",
"$",
"column_key",
",",
"$",
"index",
")",
";",
"}",
"else",
... | array_column | [
"array_column"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/ArrayObject.php#L330-L340 |
matyhtf/framework | libs/Swoole/ArrayObject.php | ArrayObject.keys | function keys($search_value = null, $strict = false)
{
return new ArrayObject(array_keys($this->array, $search_value, $strict));
} | php | function keys($search_value = null, $strict = false)
{
return new ArrayObject(array_keys($this->array, $search_value, $strict));
} | [
"function",
"keys",
"(",
"$",
"search_value",
"=",
"null",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"return",
"new",
"ArrayObject",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"array",
",",
"$",
"search_value",
",",
"$",
"strict",
")",
")",
";",
"}... | 返回数组的KEY | [
"返回数组的KEY"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/ArrayObject.php#L345-L348 |
matyhtf/framework | libs/Swoole/ArrayObject.php | ArrayObject.sort | function sort($sort_flags = SORT_REGULAR)
{
$newArray = $this->array;
sort($newArray, $sort_flags);
return new ArrayObject($newArray);
} | php | function sort($sort_flags = SORT_REGULAR)
{
$newArray = $this->array;
sort($newArray, $sort_flags);
return new ArrayObject($newArray);
} | [
"function",
"sort",
"(",
"$",
"sort_flags",
"=",
"SORT_REGULAR",
")",
"{",
"$",
"newArray",
"=",
"$",
"this",
"->",
"array",
";",
"sort",
"(",
"$",
"newArray",
",",
"$",
"sort_flags",
")",
";",
"return",
"new",
"ArrayObject",
"(",
"$",
"newArray",
")",... | 排序 | [
"排序"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/ArrayObject.php#L361-L367 |
matyhtf/framework | libs/module/GetOptionKit/src/GetOptionKit/OptionParser.php | OptionParser.takeOptionValue | function takeOptionValue($spec,$arg,$next)
{
if( $arg->containsOptionValue() ) {
$spec->setValue( $arg->getOptionValue() );
}
elseif( $next && ! $next->isOption() ) {
$spec->setValue( $next->arg );
}
else {
$spec->setValue(true);
}
} | php | function takeOptionValue($spec,$arg,$next)
{
if( $arg->containsOptionValue() ) {
$spec->setValue( $arg->getOptionValue() );
}
elseif( $next && ! $next->isOption() ) {
$spec->setValue( $next->arg );
}
else {
$spec->setValue(true);
}
} | [
"function",
"takeOptionValue",
"(",
"$",
"spec",
",",
"$",
"arg",
",",
"$",
"next",
")",
"{",
"if",
"(",
"$",
"arg",
"->",
"containsOptionValue",
"(",
")",
")",
"{",
"$",
"spec",
"->",
"setValue",
"(",
"$",
"arg",
"->",
"getOptionValue",
"(",
")",
... | /* take option value from current argument or from the next argument | [
"/",
"*",
"take",
"option",
"value",
"from",
"current",
"argument",
"or",
"from",
"the",
"next",
"argument"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/GetOptionKit/src/GetOptionKit/OptionParser.php#L72-L83 |
matyhtf/framework | libs/module/GetOptionKit/src/GetOptionKit/OptionParser.php | OptionParser.pushOptionValue | function pushOptionValue($spec,$arg,$next)
{
if( $arg->containsOptionValue() )
$spec->pushValue( $arg->getOptionValue() );
elseif( ! $next->isOption() )
$spec->pushValue( $next->arg );
} | php | function pushOptionValue($spec,$arg,$next)
{
if( $arg->containsOptionValue() )
$spec->pushValue( $arg->getOptionValue() );
elseif( ! $next->isOption() )
$spec->pushValue( $next->arg );
} | [
"function",
"pushOptionValue",
"(",
"$",
"spec",
",",
"$",
"arg",
",",
"$",
"next",
")",
"{",
"if",
"(",
"$",
"arg",
"->",
"containsOptionValue",
"(",
")",
")",
"$",
"spec",
"->",
"pushValue",
"(",
"$",
"arg",
"->",
"getOptionValue",
"(",
")",
")",
... | /*
push value to multipl value option | [
"/",
"*",
"push",
"value",
"to",
"multipl",
"value",
"option"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/GetOptionKit/src/GetOptionKit/OptionParser.php#L88-L94 |
matyhtf/framework | libs/Swoole/GeneralView.php | GeneralView.proc_upfiles | function proc_upfiles()
{
if (!empty($_FILES))
{
foreach ($_FILES as $k => $f)
{
if (!empty($_FILES[$k]['type']))
{
$_POST[$k] = $this->swoole->upload->save($k);
}
}
}
} | php | function proc_upfiles()
{
if (!empty($_FILES))
{
foreach ($_FILES as $k => $f)
{
if (!empty($_FILES[$k]['type']))
{
$_POST[$k] = $this->swoole->upload->save($k);
}
}
}
} | [
"function",
"proc_upfiles",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_FILES",
")",
")",
"{",
"foreach",
"(",
"$",
"_FILES",
"as",
"$",
"k",
"=>",
"$",
"f",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_FILES",
"[",
"$",
"k",
"]",
... | 处理上传文件 | [
"处理上传文件"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/GeneralView.php#L105-L117 |
matyhtf/framework | libs/Swoole/GeneralView.php | GeneralView.action_del | function action_del()
{
if (isset($_GET['del']))
{
$del = (int)$_GET['del'];
$this->model->del($del);
return true;
}
else
{
return false;
}
} | php | function action_del()
{
if (isset($_GET['del']))
{
$del = (int)$_GET['del'];
$this->model->del($del);
return true;
}
else
{
return false;
}
} | [
"function",
"action_del",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'del'",
"]",
")",
")",
"{",
"$",
"del",
"=",
"(",
"int",
")",
"$",
"_GET",
"[",
"'del'",
"]",
";",
"$",
"this",
"->",
"model",
"->",
"del",
"(",
"$",
"del",
... | 处理删除请求 | [
"处理删除请求"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/GeneralView.php#L122-L135 |
matyhtf/framework | libs/Swoole/GeneralView.php | GeneralView.filter_field | private function filter_field()
{
foreach ($_POST as $k => $v)
{
if (strpos($this->gets['select'], $k) === false)
{
unset($_POST[$k]);
}
}
} | php | private function filter_field()
{
foreach ($_POST as $k => $v)
{
if (strpos($this->gets['select'], $k) === false)
{
unset($_POST[$k]);
}
}
} | [
"private",
"function",
"filter_field",
"(",
")",
"{",
"foreach",
"(",
"$",
"_POST",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"gets",
"[",
"'select'",
"]",
",",
"$",
"k",
")",
"===",
"false",
")",
"{... | 过滤字段 | [
"过滤字段"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/GeneralView.php#L152-L161 |
matyhtf/framework | libs/Swoole/GeneralView.php | GeneralView.action_post | function action_post($trim = false)
{
if ($_POST)
{
$this->proc_upfiles();
if ($trim)
{
$this->trim_post();
}
if ($this->post_callback)
{
call_user_func($this->post_callback, $this);
}... | php | function action_post($trim = false)
{
if ($_POST)
{
$this->proc_upfiles();
if ($trim)
{
$this->trim_post();
}
if ($this->post_callback)
{
call_user_func($this->post_callback, $this);
}... | [
"function",
"action_post",
"(",
"$",
"trim",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"_POST",
")",
"{",
"$",
"this",
"->",
"proc_upfiles",
"(",
")",
";",
"if",
"(",
"$",
"trim",
")",
"{",
"$",
"this",
"->",
"trim_post",
"(",
")",
";",
"}",
"if"... | 处理数据提交请求
@param $trim
@return bool | [
"处理数据提交请求"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/GeneralView.php#L168-L217 |
matyhtf/framework | libs/Swoole/GeneralView.php | GeneralView.action_detail | function action_detail()
{
if (isset($_GET['id']))
{
$this->vars['det'] = $this->model->get((int)$_GET['id'])->get();
if ($this->detail_callback)
{
call_user_func($this->detail_callback, $this);
}
$this->swoole->tpl->assign(... | php | function action_detail()
{
if (isset($_GET['id']))
{
$this->vars['det'] = $this->model->get((int)$_GET['id'])->get();
if ($this->detail_callback)
{
call_user_func($this->detail_callback, $this);
}
$this->swoole->tpl->assign(... | [
"function",
"action_detail",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"vars",
"[",
"'det'",
"]",
"=",
"$",
"this",
"->",
"model",
"->",
"get",
"(",
"(",
"int",
")",
"$",
"_GET",
... | 处理详细内容请求
@return unknown_type | [
"处理详细内容请求"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/GeneralView.php#L223-L238 |
matyhtf/framework | libs/Swoole/GeneralView.php | GeneralView.action_list | function action_list()
{
$_model = $this->model;
$gets = $this->gets;
$gets['page'] = empty($_REQUEST[self::$page_key]) ? 1 : $_REQUEST[self::$page_key];
$gets['pagesize'] = empty($_REQUEST[self::$pagesize_key]) ? self::$pagesize_default : $_REQUEST[self::$pagesize_key];
/**... | php | function action_list()
{
$_model = $this->model;
$gets = $this->gets;
$gets['page'] = empty($_REQUEST[self::$page_key]) ? 1 : $_REQUEST[self::$page_key];
$gets['pagesize'] = empty($_REQUEST[self::$pagesize_key]) ? self::$pagesize_default : $_REQUEST[self::$pagesize_key];
/**... | [
"function",
"action_list",
"(",
")",
"{",
"$",
"_model",
"=",
"$",
"this",
"->",
"model",
";",
"$",
"gets",
"=",
"$",
"this",
"->",
"gets",
";",
"$",
"gets",
"[",
"'page'",
"]",
"=",
"empty",
"(",
"$",
"_REQUEST",
"[",
"self",
"::",
"$",
"page_ke... | 处理内容列表请求
@return unknown_type | [
"处理内容列表请求"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/GeneralView.php#L244-L265 |
matyhtf/framework | libs/Swoole/Protocol/RPCServer.php | RPCServer.encode | static function encode($data, $type = self::DECODE_PHP, $uid = 0, $serid = 0)
{
//启用压缩
if ($type & self::DECODE_GZIP)
{
$_type = $type & ~self::DECODE_GZIP;
$gzip_compress = true;
}
else
{
$gzip_compress = false;
$_type ... | php | static function encode($data, $type = self::DECODE_PHP, $uid = 0, $serid = 0)
{
//启用压缩
if ($type & self::DECODE_GZIP)
{
$_type = $type & ~self::DECODE_GZIP;
$gzip_compress = true;
}
else
{
$gzip_compress = false;
$_type ... | [
"static",
"function",
"encode",
"(",
"$",
"data",
",",
"$",
"type",
"=",
"self",
"::",
"DECODE_PHP",
",",
"$",
"uid",
"=",
"0",
",",
"$",
"serid",
"=",
"0",
")",
"{",
"//启用压缩",
"if",
"(",
"$",
"type",
"&",
"self",
"::",
"DECODE_GZIP",
")",
"{",
... | 打包数据
@param $data
@param $type
@param $uid
@param $serid
@return string | [
"打包数据"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/RPCServer.php#L202-L233 |
matyhtf/framework | libs/Swoole/Protocol/RPCServer.php | RPCServer.decode | static function decode($data, $unseralize_type = self::DECODE_PHP)
{
if ($unseralize_type & self::DECODE_GZIP)
{
$unseralize_type &= ~self::DECODE_GZIP;
$data = gzdecode($data);
}
switch ($unseralize_type)
{
case self::DECODE_JSON:
... | php | static function decode($data, $unseralize_type = self::DECODE_PHP)
{
if ($unseralize_type & self::DECODE_GZIP)
{
$unseralize_type &= ~self::DECODE_GZIP;
$data = gzdecode($data);
}
switch ($unseralize_type)
{
case self::DECODE_JSON:
... | [
"static",
"function",
"decode",
"(",
"$",
"data",
",",
"$",
"unseralize_type",
"=",
"self",
"::",
"DECODE_PHP",
")",
"{",
"if",
"(",
"$",
"unseralize_type",
"&",
"self",
"::",
"DECODE_GZIP",
")",
"{",
"$",
"unseralize_type",
"&=",
"~",
"self",
"::",
"DEC... | 解包数据
@param string $data
@param int $unseralize_type
@return string | [
"解包数据"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/RPCServer.php#L241-L258 |
matyhtf/framework | libs/Swoole/Protocol/RPCServer.php | RPCServer.addNameSpace | function addNameSpace($name, $path)
{
if (!is_dir($path))
{
throw new \Exception("$path is not real path.");
}
Swoole\Loader::addNameSpace($name, $path);
} | php | function addNameSpace($name, $path)
{
if (!is_dir($path))
{
throw new \Exception("$path is not real path.");
}
Swoole\Loader::addNameSpace($name, $path);
} | [
"function",
"addNameSpace",
"(",
"$",
"name",
",",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"$path is not real path.\"",
")",
";",
"}",
"Swoole",
"\\",
"Loader",
"::",
... | 增加命名空间
@param $name
@param $path
@throws \Exception | [
"增加命名空间",
"@param",
"$name",
"@param",
"$path"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/RPCServer.php#L277-L284 |
matyhtf/framework | libs/Swoole/Protocol/RPCServer.php | RPCServer.verifyUser | protected function verifyUser($user, $password)
{
if (!isset($this->userList[$user]))
{
return false;
}
if ($this->userList[$user] != $password)
{
return false;
}
return true;
} | php | protected function verifyUser($user, $password)
{
if (!isset($this->userList[$user]))
{
return false;
}
if ($this->userList[$user] != $password)
{
return false;
}
return true;
} | [
"protected",
"function",
"verifyUser",
"(",
"$",
"user",
",",
"$",
"password",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"userList",
"[",
"$",
"user",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",... | 验证用户名密码
@param $user
@param $password
@return bool | [
"验证用户名密码"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/RPCServer.php#L302-L313 |
matyhtf/framework | libs/Swoole/Protocol/RPCServer.php | RPCServer.call | protected function call($request, $header)
{
if (empty($request['call']))
{
return array('errno' => self::ERR_PARAMS);
}
/**
* 侦测服务器是否存活
*/
if ($request['call'] === 'PING')
{
return array('errno' => 0, 'data' => 'PONG');
... | php | protected function call($request, $header)
{
if (empty($request['call']))
{
return array('errno' => self::ERR_PARAMS);
}
/**
* 侦测服务器是否存活
*/
if ($request['call'] === 'PING')
{
return array('errno' => 0, 'data' => 'PONG');
... | [
"protected",
"function",
"call",
"(",
"$",
"request",
",",
"$",
"header",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"request",
"[",
"'call'",
"]",
")",
")",
"{",
"return",
"array",
"(",
"'errno'",
"=>",
"self",
"::",
"ERR_PARAMS",
")",
";",
"}",
"/**... | 调用远程函数
@param $request
@return array | [
"调用远程函数"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/RPCServer.php#L320-L377 |
matyhtf/framework | libs/Swoole/Protocol/RPCServer.php | RPCServer.close | protected function close($fd)
{
$this->server->close($fd);
unset($this->_buffer[$fd], $this->_headers[$fd]);
} | php | protected function close($fd)
{
$this->server->close($fd);
unset($this->_buffer[$fd], $this->_headers[$fd]);
} | [
"protected",
"function",
"close",
"(",
"$",
"fd",
")",
"{",
"$",
"this",
"->",
"server",
"->",
"close",
"(",
"$",
"fd",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_buffer",
"[",
"$",
"fd",
"]",
",",
"$",
"this",
"->",
"_headers",
"[",
"$",
"fd... | 关闭连接
@param $fd | [
"关闭连接"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/RPCServer.php#L383-L387 |
matyhtf/framework | libs/Swoole/Protocol/RPCServer.php | RPCServer.addAllowIP | function addAllowIP($ip)
{
if (Swoole\Validate::ip($ip))
{
$this->ipWhiteList[$ip] = true;
$this->verifyIp = true;
}
else
{
throw new Swoole\Exception\InvalidParam("require ip address.");
}
} | php | function addAllowIP($ip)
{
if (Swoole\Validate::ip($ip))
{
$this->ipWhiteList[$ip] = true;
$this->verifyIp = true;
}
else
{
throw new Swoole\Exception\InvalidParam("require ip address.");
}
} | [
"function",
"addAllowIP",
"(",
"$",
"ip",
")",
"{",
"if",
"(",
"Swoole",
"\\",
"Validate",
"::",
"ip",
"(",
"$",
"ip",
")",
")",
"{",
"$",
"this",
"->",
"ipWhiteList",
"[",
"$",
"ip",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"verifyIp",
"=",
"... | 添加访问规则
@param $ip
@throws Swoole\Exception\InvalidParam | [
"添加访问规则"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/RPCServer.php#L394-L406 |
matyhtf/framework | libs/Swoole/Protocol/RPCServer.php | RPCServer.addAllowUser | function addAllowUser($user, $password)
{
$this->userList[$user] = $password;
$this->verifyUser = true;
} | php | function addAllowUser($user, $password)
{
$this->userList[$user] = $password;
$this->verifyUser = true;
} | [
"function",
"addAllowUser",
"(",
"$",
"user",
",",
"$",
"password",
")",
"{",
"$",
"this",
"->",
"userList",
"[",
"$",
"user",
"]",
"=",
"$",
"password",
";",
"$",
"this",
"->",
"verifyUser",
"=",
"true",
";",
"}"
] | 添加用户许可
@param $user
@param $password | [
"添加用户许可"
] | train | https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/RPCServer.php#L413-L417 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.