// ftp information $ ftp_server = "xxxxxxxxxxx"; // FTP server address $ username = "xxx"; // To query the directory $ userpassword = "xxxxxx"; //> The password // Database information $ localhost = "LocalHost"; // is generally localhost $ datauser = "xxx"; // Database Username $ datapassword = "xxxxx"; // Database User Password $ Database = "xxxxx"; // Database Name
// Data table creation information Realfly is a table name // Create Table Realfly (// id tinyint (4) unsigned not null auto_increment, // Date Date DEFAULT '0000-00-00' NOT NULL, // Time Time Default '00: 00: 00' NOT NULL, // Content Longtext Not Null, // Key ID (ID) //);
?>
################################################################ #### Program: FTP Search Engine Recrese Function File ## File: Class.php ## Name: Network Knight ## Use Technology: PHP & Mysql ## Version: v1.0 ## Contact: Shakeespareshmily@sina.com.cn # ######################################################################################################################################################################################################################################################################################################## #
Function Happy ($ FTP_STREAM, $ DIRECTORY, $ LINK)
{
IF (IS_DIR ($ DIRECTORY))
{
//! "Y" "."-".date ("" ");" D ");
/ / $ content = $ DIRECTORY;
// $ time = Date ("H: i: s");
// $ query = "INTO REALFLY VALUES (',' ',' $ Today ',' $ TIME ',' $ Content ';";
// mysql_query ($ query, $ link);
// $ color = "ff3399";
// echo "". $ DIRECTORY. " font>
"; $ results = ftp_nlist ($ ftp_stream, $ DIRECTORY);
For ($ j = 0; $ j <= count ($ result); $ j ) {
Happy ($ FTP_STREAM, $ Result [$ J], $ LINK);
}
}
Else {
$ base = basename ($ DIRECTORY); $ file = evLode (".", $ basename);
$ ID = $ i ;
$ TODAY = (Date ("y"). "-"). "-"). "-". Date ("D"));
$ content = $ DIRECTORY;
// $ content4 = $ DIRECTORY;
$ TIME = DATE ("H: I: S");
$ query = "INSERT INTO REALFLY VALUES ('$ file [0],' $ ID ',' $ Today ',' $ TIME ',' $ Content ');";
MySQL_QUERY ($ query, $ link);
Echo $ DIRECTORY. "
";
}
?>
Include ("./search_ini.php"); include ("./class.php" );############################ ######################## 程序: ftp search engine main file ## file: search.php ## Name: Network Knight ## : Php & mysql ## version: v1.0 ## Contact: shakespareshmily@sina.com.cn ####################################################################################################################################################################################################################################################################### #######################################
$ Ftp_stream = ftp_connect ($ ftp_server, 21); $ login = ftp_login ($ ftp_stream, "$ username", "$ userpassword"); if (!! $ Login || $ ftp_stream) {echo "can not connect to $ ftp_server" Echo "try again";} else {echo " Connect to $ ftp_server
Congratulations! Font>
"} $ link = mysql_pconnect ("$ localhost", "$ datausword"); mysql_select_db ("$ database", $ link); $ this = ftp_pwd ($ ftp_stream); $ this = @ ftp_chdir ($ ftp_stream, "); $ Result = ftp_nlist ($ FTP_STREAM, $ THIS); for ($ I = 0; $ I <= Count ($ RESULT); $ I ) {IF (is_dir ($ Result [$ I])) {happy ($ ftp_stream $ Result [$ I], $ LINK);} else {Echo $ Result [$ I]. "
"; $ basename = basename ($ Result [$ I]); $ file = evLode ("." $ BaseName); $ ID = $ i; $ Today = (Date ("y"). "-"). "-". Date ("D"); $ content = "$ Result [$ I] "; $ TIME = DATE (" H: I: S "); $ query =" Insert Into Rea Lfly Values ('$ file [0],' $ ID ',' $ Today ',' $ TIME ',' $ Content '); "; MySQL_Query ($ query, $ link);}}?>
The above is the search processing program in the background, below is the user query handler
###################################################################################
# Software Name: FTP Search Engine Display Page #
# Version: v1.0 #
# Useful technology: PHP & mysql #
# Author: Knight ## Network Contact: shakespareshmily@sina.com.cn #
###################################################################################
INCLUDE ("./search_ini.php");
// Connect to Database
$ link = mysql_pconnect ("$ localhost", "$ datauser", "$ datawordword") or Die ("Unable to connect the server, please try again!");
// Select Database
MySQL_SELECT_DB ("$ Database", $ LINK);
// make query
$ query = "SELECT NAME, Content from realfly where name = '$ query1'"; echo "The fields you are inquiry:"; echo "$ query1.
"; $ i = 0; $ results = mysql_query ($ Query, $ LINK); if ($ results) {while (list ($ name, $ content) = mysql_fetch_row ($ result)) {echo "The result you can query:"; $ content3 = "ftp: // XXXXXXXX "; // Your FTP site name $ content2 = stristr ($ DIRECTORY," / var / ftp "); $ content = $ content3. $ content2; echo $ Content a >
"; $ i ;}}
IF ($ I == 0) {$ color = "ff3399"; echo " is amazing, actually did not find, huh, huh ~~, try again! < / font>
";} else echo" Congratulations, the Dongdong you have to find, download it quickly! "
";?>
Requirently needed:
1: Generate the background: Since our webmaster makes me make a FTP search similar to Northern Tian Tianwang, it is created for the school to download the software in the school. Of course, its search ability is far less powerful, and it is not a true search engine, but it can complete the function of traversing in the FTP directory (if your directory is not too deep --- it can handle 18 Layer directory)
2: The above programs must be placed under the directory you want to search. - The reason is permission
3: Existing problems
A: If the file catalog processing is too deep (such as 30 floors, although few people do, but it will skip too deep directory - because the server is the server about the runtime limit) --- ---- I have already thought of a solution (theoretical stage, because it is now busy paying the CPA exam, so there is no implementation) ------ ie mimic the multi-thread download method such as flash Get. Get files in the current directory, and the folder simultaneously generates an array to search each folder or search at the same time. This parent directory ----- This problem is easy to solve but increase the task of processing, plus the recent time improvement, so it has been placed ^ - ^
Confucius, hope and discretion