<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">program : Spr2[search_html] </span> </span></li><li><span><span class="comment">Author : uchinaboy </span> </span></li><li class="alt"><span><span class="comment">E-mail : uchinaboy@163.com </span> </span></li><li><span><span class="comment">QQ : 16863798 </span> </span></li><li class="alt"><span><span class="comment">Date : 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><span class="keyword">while</span><span> (</span><span class="vars">$filename</span><span> = readdir(</span><span class="vars">$handle</span><span>)) { </span></li><li class="alt"><span class="comment">//echo $path."/".$filename."<br>"; </span><span> </span></span></li> <li> <span class="vars">$newpath</span><span> = </span><span class="vars">$path</span><span>.</span><span class="string">"/"</span><span>.</span><span class="vars">$filename</span><span>; </span> </li> <li class="alt"> <span class="vars">$check_type</span><span> = preg_match(</span><span class="string">"/.html?$/"</span><span>, </span><span class="vars">$filename</span><span>); </span> </li> <li> <span class="keyword">if</span><span> (</span><span class="func">is_file</span><span>(</span><span class="vars">$newpath</span><span>) && </span><span class="vars">$check_type</span><span>) { </span> </li> <li class="alt"> <span class="vars">$fp</span><span> = </span><span class="func">fopen</span><span>(</span><span class="vars">$newpath</span><span>, </span><span class="string">"r"</span><span>); </span> </li> <li> <span class="vars">$msg</span><span> = </span><span class="func">fread</span><span>(</span><span class="vars">$fp</span><span>, </span><span class="func">filesize</span><span>(</span><span class="vars">$newpath</span><span>)); </span> </li> <li class="alt"> <span>fclose(</span><span class="vars">$fp</span><span>); </span> </li> <li> <span>match_show(</span><span class="vars">$key</span><span>, </span><span class="vars">$msg</span><span>, </span><span class="vars">$newpath</span><span>, </span><span class="vars">$filename</span><span>); </span> </li> <li class="alt"><span>} </span></li> <li> <span class="keyword">if</span><span> (</span><span class="func">is_dir</span><span>(</span><span class="vars">$path</span><span>.</span><span class="string">"/"</span><span>.</span><span class="vars">$filename</span><span>) && (</span><span class="vars">$filename</span><span> != </span><span class="string">"."</span><span>) && (</span><span class="vars">$filename</span><span> != </span><span class="string">".."</span><span>)) { </span> </li> <li class="alt"> <span class="comment">//echo "<BR><BR><BR>".$newpath."<BR><BR><BR>"; </span><span> </span> </li> <li> <span>get_msg(</span><span class="vars">$path</span><span>.</span><span class="string">"/"</span><span>.</span><span class="vars">$filename</span><span>); </span> </li> <li class="alt"><span>} </span></li> <li><span>} </span></li> <li class="alt"> <span class="func">closedir</span><span>(</span><span class="vars">$handle</span><span>); </span> </li> <li> <span class="keyword">return</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">$newpath</span><span>, </span><span class="vars">$filename</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">$key</span><span> = </span><span class="func">chop</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><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">$key</FONT>"</span><span>, </span><span class="vars">$res</span><span>[0]); </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">true</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http://www.bkjia.com/PHPjc/486037.html</span><span id="genre" itemprop="genre">TechArticle</span><span id="description" itemprop="description">?php /**************************************************** program:Spr2[search_html] Author:uchinaboy E-mail:uchinaboy@163.com QQ:16863798 Date:2001-8-9 ***************************...</span> </div> <div class="art_confoot"></div></span> </li> </ol>