uTools-Manuals/docs/php/tcpwrap_check.html
2019-04-08 23:22:26 +08:00

129 lines
4.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Performs a tcpwrap check</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.tcpwrap-check" class="refentry">
<div class="refnamediv">
<h1 class="refname">tcpwrap_check</h1>
<p class="verinfo">(PECL tcpwrap &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">tcpwrap_check</span> &mdash; <span class="dc-title">Performs a tcpwrap check</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.tcpwrap-check-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>tcpwrap_check</strong></span>
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$daemon</code></span>
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$address</code></span>
[, <span class="methodparam"><span class="type">string</span> <code class="parameter">$user</code></span>
[, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$nodns</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
]] ) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
This function consults the <var class="filename">/etc/hosts.allow</var> and
<var class="filename">/etc/hosts.deny</var> files to check if access to service
<code class="parameter">daemon</code> should be granted or denied for a client.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.tcpwrap-check-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">daemon</code></dt>
<dd>
<p class="para">
The service name.
</p>
</dd>
<dt>
<code class="parameter">address</code></dt>
<dd>
<p class="para">
The client remote address. Can be either an IP address or a domain name.
</p>
</dd>
<dt>
<code class="parameter">user</code></dt>
<dd>
<p class="para">
An optional user name.
</p>
</dd>
<dt>
<code class="parameter">nodns</code></dt>
<dd>
<p class="para">
If <code class="parameter">address</code> looks like domain name then DNS is
used to resolve it to IP address; set <code class="parameter">nodns</code> to
<strong><code>TRUE</code></strong> to avoid this.
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.tcpwrap-check-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
This function returns <strong><code>TRUE</code></strong> if access should be granted, <strong><code>FALSE</code></strong> otherwise.
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.tcpwrap-check-examples">
<h3 class="title">范例</h3>
<div class="example" id="example-5678">
<p><strong>Example #1 Deny all connections from localhost</strong></p>
<div class="example-contents"><p>
If your <var class="filename">/etc/hosts.deny</var> file contains:
</p></div>
<div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">php: 127.0.0.1</pre>
</div>
</div>
<div class="example-contents"><p>
And your code looks like:
</p></div>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">tcpwrap_check</span><span style="color: #007700">(</span><span style="color: #DD0000">'php'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$_SERVER</span><span style="color: #007700">[</span><span style="color: #DD0000">'REMOTE_ADDR'</span><span style="color: #007700">]))&nbsp;{<br />&nbsp;&nbsp;die(</span><span style="color: #DD0000">'You&nbsp;are&nbsp;not&nbsp;welcome&nbsp;here'</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</div>
<div class="refsect1 seealso" id="refsect1-function.tcpwrap-check-seealso">
<h3 class="title">参见</h3>
<p class="para">
For more details please consult hosts_access(3) man page.
</p>
</div>
</div></div></div></body></html>