ホームページ >バックエンド開発 >PHPチュートリアル >サイト検索 HTML バージョン_PHP チュートリアル

サイト検索 HTML バージョン_PHP チュートリアル

WBOY
WBOYオリジナル
2016-07-13 17:42:371077ブラウズ

<ol class="dp-c">
<li class="alt"><span><span><?php </span></span></li><li><span class="comment">/*************************************************** </span> </li><li class="alt"><span><span class="comment">プログラム : Spr2[search_html] </span> </span></li><li><span><span class="comment">著者 : uchinaboy </span> </span></li><li class="alt"><span><span class="comment">電子メール : uchinaboy@163.com </span> </span></li><li><span><span class="comment">QQ : 16863798 </span> </span></li><li class="alt"><span><span class="comment">日付 : 2001-8-9 </span> </span></li><li><span><span class="comment">************************************* ***************/</span><span> </span></span></li><li class="alt"><span class="comment">//require("config.inc.php");   </span><span> </span></li><li><span> </span></li><li class="alt"><span class="keyword">function</span><span> get_msg(</span><span class="vars">$path</span><span>) { </span></li><li><span class="keyword">global</span><span> </span><span class="vars">$key </span><span>、</span><span class="vars">$i</span><span>;    </span></li><li class="alt"><span class="vars">$handle</span><span> = opendir(</span><span class="vars">$path</span><span>);    </span></li><li>while<span class="keyword"></span> (<span></span>$filename<span class="vars"></span> = readdir(<span></span>$handle<span class="vars"></span>)) { <span></span></li><li class="alt">//echo $path."/".$filename."<br>" ;   <span class="comment"></span> <span></span></span></span></li>
<li>$newpath<span class="vars"></span> = <span></span>$path<span class="vars"></span>.<span></span>"/"<span class="string"></span>.<span></span>$ファイル名<span class="vars"></span>;    <span></span>
</li>
<li class="alt">$check_type<span class="vars"></span> = preg_match(<span></span>"/.html?$/"<span class="string"></span>, <span></span>$filename<span class="vars"></span>);    <span></span>
</li>
<li>if<span class="keyword"></span>(<span></span>is_file<span class="func"></span>(<span></span>$newpath<span class="vars"></span>) && <span></span>$check_type<span class="vars"></span>) { <span></span>
</li>
<li class="alt">$fp<span class="vars"> </span> = <span></span>fopen<span class="func"></span>(<span></span>$newpath<span class="vars"> </span>、 <span></span>「r」<span class="string"></span>);    <span></span>
</li>
<li>$msg<span class="vars"></span> = <span></span>fread<span class="func"></span>(<span></span>$fp<span class="vars"></span>, <span></span>ファイルサイズ<span class="func"></span>(<span></span>$newpath<span class="vars"></span>));    <span></span>
</li>
<li class="alt">fclose(<span></span>$fp<span class="vars"></span>);    <span></span>
</li>
<li>match_show(<span></span>$key<span class="vars"></span>, <span></span>$msg<span class="vars"></span>, <span></span>$newpath<span class="vars"></span>, <span></span>$filename<span class="vars"></span>);    <span></span>
</li>
<li class="alt">} <span></span>
</li>
<li>if<span class="keyword"></span> (<span></span>is_dir<span class="func"></span>(<span></span>$パス<span class="vars"></span>.<span></span>"/"<span class="string"></span>.<span></span>$ファイル名<span class="vars"></span>) && (<span></span>$ファイル名<span class="vars"></span> ! = <span></span>"."<span class="string"></span>) && (<span></span>$ファイル名<span class="vars"></span> != <span></span>".."<span class="string"></span>)) { <span></span>
</li>
<li class="alt">//echo "<BR><BR><BR&gと; ".$newpath."<BR><BR><BR>";   <span class="comment"></span> <span></span></li><li>get_msg(<span></span>$パス<span class="vars"></span>.<span></span>"/"<span class="string"></span>.<span></span>$ファイル名<span class="vars"></span>);    <span></span></li><li class="alt">} <span></span></li><li>}    </span></li><li class="alt"><span class="func">closedir</span><span>(</span><span class="vars">$handle</span><span>);    </span></li><li><span class="keyword">戻る</span><span> </span><span class="vars">$i</span><span>;    </span></li><li class="alt"><span>} </span></li><li><span> </span></li><li class="alt"><span class="keyword">function</span><span> match_show(</span><span class="vars">$key</span><span>, </span><span class="vars">$msg</span><span>, </span><span class="vars">$newパス</span><span>, </span><span class="vars">$ファイル名</span><span>) { </span></li><li> <span class="keyword">グローバル</span><span> </span><span class="vars">$key</span><span>、</span><span class="vars">$i</span><span>;    </span></li><li class="alt"><span class="vars">$key</span><span> = </span><span class="func">チョップ</span><span>(</span><span class="vars">$key</span><span>);    </span></li><li><span class="keyword">if</span><span> (</span><span class="vars">$key</span><span>) { </span></li><li class="alt"><span class="vars">$msg</span><span> = preg_replace(</span><span class="string">"/<style>.+</style>/is" <span>、</span><span class="string"> ""</span><span>、</span><span class="vars">$msg</span><span>);    </span>
</li>
<li>
<span class="vars">$msg</span><span> = </span><span class="func">str_replace</span><span>(</span><span class="string">" "</span><span>, </span><span class="string">""</span><span>, </span><span class="vars">$msg</span><span>);    </span>
</li>
<li class="alt">
<span class="vars">$msg</span><span> = preg_replace(</span><span class="string">"/<[^>]+>/"</span><span>, </span><span class="string">""</span><span>, </span><span class="vars">$msg</span><span>);    </span>
</li>
<li>
<span class="vars">$value</span><span> = preg_match(</span><span class="string">"/.*$key.*/i"</span><span>, </span><span class="vars">$msg</span><span>, </span><span class="vars">$res</span><span>);    </span>
</li>
<li class="alt">
<span class="keyword">if</span><span> (</span><span class="vars">$value</span><span>) { </span>
</li>
<li>
<span class="vars">$res</span><span>[0] = preg_replace(</span><span class="string">"/$key/i"</span><span>, </span>) <span class="string">"<font size="2" color="red"><span>, </span><span class="vars">$res</span><span>[0]);    </span></font></span>
</li>
<li class="alt">
<span class="vars">$i</span><span>++;    </span>
</li>
<li>
<span class="vars">$link</span><span> = </span><span class="vars">$newpath</span><span>;    </span>
</li>
<li class="alt">
<span>print </span><span class="string">"<a href="$link">$filename</a><BR>"</span><span>;    </span>
</li>
<li>
<span>print </span><span class="vars">$res</span><span>[0].</span><span>
<p align="left"></p>
<div style="display:none;">
<span id="url" itemprop="url">http://www.bkjia.com/PHPjc/486037.html</span><span id="indexUrl" itemprop="indexUrl">www.bkjia.com</span><span id="isOriginal" itemprop="isOriginal">tru​​e</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http://www.bkjia.com/PHPjc/486037.html</span><span id="genre" itemprop="genre">技術記事</span><span id="description" itemprop="description"> ?php /********************************************** ***** プログラム:Spr2[search_html] 著者:uchinaboy E-mail:uchinaboy@163.com QQ:16863798 日付:2001-8-9 ***************** **********...</span>
</div>
<div class="art_confoot"></div></span>
</li>
</ol>
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。