PHP站内搜索
search.php文件
/****************************************************
原作者: uchinaboy
特点:无需mysql支持;速度快;无需设置路径,放在哪级目录下,就搜索该目录和子目录;可以
搜索一切文本类型的文件;显示文件相关内容;关键词自动高亮显示。
修改内容:增加了自动分页和风格设置文件。
搜索框代码(请单独存为html文件,如果放在search.php相同目录下,无需修改):
****************************************************/
require ("search.inc");
if (function_exists("set_time_limit") && !get_cfg_var('safe_mode')){
set_time_limit(600);}
function get_msg($path) {
global $key, $i;
$handle = opendir($path);
while ($filename = readdir($handle)) {
//echo $path."/".$filename."
";
$newpath = $path."/".$filename;
if (is_file($newpath)) {
$fp = fopen($newpath, "r");
$msg = fread($fp, filesize($newpath));
fclose($fp);
match_show($key, $msg, $newpath, $filename);
}
if (is_dir($path."/".$filename) && ($filename != ".") && ($filename != "..")) {
//echo "
".$newpath."
";
get_msg($path."/".$filename);
}
}
closedir($handle);
return $i;
}
function match_show($key, $msg, $newpath, $filename) {
global $ar, $i;
$key = chop($key);
if($key) { $check_type = preg_match("/.html?$/", $filename);
if($check_type) {$title = getHtmlTitle($msg);}
$msg = preg_replace("//is", "", $msg);
$msg = preg_replace("/]+>/", "", $msg);
$value = preg_match("/.*$key.*/i", $msg, $res);
if($value) {
$res[0] = preg_replace("/$key/i", "$key", $res[0]);
$k = $res[0];
$k = strrchr($k, " $k = substr($k, 1, 100);
$k = "$key if($title) {$m = $title;} else {$m = $filename;}
$i++;
$link = $newpath;
$ar[] = "$i.◆$m
" .$k."
";
}
}else {
echo "请输入关键词";
exit;
}
}
function getHtmlTitle($msg) {
/* Locate where
$lBound = strpos($msg, '
if ($lBound return;
/* Locate where
$uBound = strpos($msg, '
if ($uBound return;
/* Clean HTML and PHP tags out of $title with the madness below. */
$title = ereg_replace("[tnr]", '', substr($msg, $lBound, $uBound -
$lBound));
$title = trim(strip_tags($title));
if (strlen($title) return;
return $title;
}
$i = get_msg(".");
if (empty($page)) $page=1;
$maxresult=($page*20);
$resultcount = count($ar);
if ($resultcount%20==0) $maxpageno=$resultcount/20;
else $maxpageno=floor($resultcount/20)+1;
if ($page>$maxpageno) { $page=$maxpageno; $pagemax=$resultcount-1; $pagemin=max
(0,$result_count-20);}
elseif ($page==1) {$pagemin=0; $pagemax=min($result_count-1,20-1); }
else { $pagemin=min($resultcount-1,20*($page-1)); $pagemax=min($resultcount-
1,$pagemin+20-1); }
$maxresult=min($maxresult,$resultcount);
echo "
";
echo "浩园软件检索结果";
echo "
";
for ($i=max(0,$maxresult-20); $i print $ar[$i];
}
echo "
";
echo " 已经搜索到了 $resultcount 条信息";
$nextpage=$page+1;
$previouspage=$page-1;
echo " --- [ 搜索下 20
个结果 ]";
echo " [ 返回上 20
个结果 ]";
exit;
?>
search.inc文件

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.
