PHP Search

xiaoxiao2021-03-05  21

Search.php

/ ************************************************** ***

Author: uchinaboy

Features: No mysql support; fast; no need to set the path, search this directory and subdirectory;

Search for all text types of files; display file related content; keywords are automatically highlighted.

Modify content: Added an automatic paging and style setting file.

Search box code (please save it separately as an HTML file, if you put it in the same directory in Search.php, there is no need to modify it):

Method = "post" Action = "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 ($ hand)) {

// echo $ path. "/". $ filename. "
";

$ newpath = $ path. "/". $ filename;

IF (is_file ($ newpath) {

$ fp = fopen ($ newpath, "r");

$ msg = fread ($ FP, FileSize);

Fclose ($ fp);

Match_show ($ KEY, $ MSG, $ NewPath, $ filename);

}

IF (IS_DIR ($ PATH. "/" && ($ 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 ("/