& Lt ;? This program is a search, currently designed to serve the Document Library. Editor: Kong Xiuxiang. Date: 2001410if (! $ UploadAction): require & quot; config. php3 & quot; if (! Isset ($ table) {$ table & quot; artical & quot;} * $ link_id // This program is used for a search. Currently, it is designed to serve the Document Library.
// Editor: Kong Xiuxiang. Date: 2001/4/10
If (! $ UploadAction ):
Require "config. php3 ";
If (! Isset ($ table )){
// $ Table = "artical ";
}
/*
$ Link_id = @ MySQL_CONNECT ($ hostname, $ dbusername, $ dbpassWord) or die ("cannot connect to the database! ");
@ Mysql_select_db ("$ dbname") or die ("You cannot select a database! ");
$ Q = "select count (id) from $ table where 1 ";
$ Result = @ mysql_query ($ q );
$ Row = @ mysql_fetch_array ($ result );
$ R_count = $ row ["count (artical_id)"];
*/
?>
Database search
It takes a long time to run the program. |
Else:
Require "config. php3 ";
$ UploadAction = 0;
$ Added = 0;
$ Die = 0;
$ Single_chinese = 0;
$ TimeLimit = 0;/* Set the time-out period. The default time is 30 seconds. if it is set to 0, the time-out period is not limited */
Set_time_limit ($ TimeLimit );
If ($ data_search = ""){
// Complete the database index
Header ("location: \ PRogs \ data_index.php3 ");
// $ Msg = "The search content cannot be blank. ";
// Xueroom_error_exit ($ msg, $ PHP_SELF );
}
$ Link_id = @ MYSQL_CONNECT ($ hostname, $ dbusername, $ dbpassword) or die ("cannot connect to the database! ");
@ Mysql_select_db ("$ dbname") or die ("You cannot select a database! ");
// SELECT id, file_name, artical_author from textfile where 1 LIMIT 0, 30
If ($ table = "artical ")
{
$ Sid = "artical_id ";
$ Stitle = "artical_title ";
$ Sauthor = "artical_author ";
$ Sdata = "artical_data ";
$ Prog = "readfile. php3 ";
If ($ a_data = "month ")
$ Key_where = "where origin_periodical rlike '^. * $ data_search .*'";
}
If ($ a_data = "data ")
$ Key_where = "where $ sdata rlike '^. * $ data_search .*'";
If ($ a_data = "title ")
$ Key_where = "where $ stitle rlike '^. * $ data_search .*'";
If ($ a_data = "author ")
$ Key_where = "where $ sauthor rlike '^. * $ data_search .*'";
// $ Q = "select $ sid, $ stitle, $ sauthor from $ table where $ sdata rlike '^. * $ data_search. *' order by $ stitle ";
If ($ a_data = "data") & (strlen ($ data_search) = 2 )){
$ Q = "select $ sid, $ stitle, $ sauthor, $ sdata from $ table $ key_where order by $ stitle ";
$ Single_chinese = 1;
}
Else {
$ Q = "select $ sid, $ stitle, $ sauthor from $ table $ key_where order by $ stitle ";
}
$ Index_data = "";
$ Count = 0;
$ Result = @ mysql_query ($ q );
If (! $ Result ){
$ Msg = "no matching record. ";
Xueroom_error_exit ($ msg, $ PHP_SELF );
}
While ($ row = @ mysql_fetch_array ($ result )){
If ($ single_chinese )&&(! MyStrPos ($ row [$ sdata], $ data_search )))
Continue;
Else
{
$ Id = $ row [$ sid];
$ Title = $ row [$ stitle];
$ Author = $ row [$ sauthor];
If ($ table = "textfile ")
$ Title = preg_replace ("/. txt/", "", $ title );
// $ Data = $ row ["artical_data"];
// If (myStrPos ($ data, $ data_search) // You can search for a single Chinese character.
// If (strpos ($ data, $ data_search) {// use this simplified method when it is greater than one Chinese character, which is faster.
$ Index_data. ="$ TitleAuthor: $ author";
$ Count ++;
// Fputs ($ fp ,"$ TitleAuthor: $ author");
//}
}
}
@ Mysql_free_result ($ result );
Mysql_close ($ link_id );
Set_time_limit (30 );
If ($ index_title = ""){
$ Index_title = "";
}
$ Index_title = $ index_title. "_". $ data_search;
$ Html_header =" $ Index_title";
$ Html_header. = "$ index_titlern ";
$ Dte_created = date ('Y-m-d H: I: s ');
$ Html_header. = "$ index_describe found $ count/query date: $ dte_createdrn ";
$ Html_header. ="
Rn ";$ Data = $ html_header. $ index_data;$ Data. ="
";/* If (strlen ($ index_file) = 0 ){Header ("Content-type: text/html ");Echo $ data;}Else{$ In_file = "$ index_file ";$ Index_file = "\ index \". $ index_file;$ Fp = indexfile ($ index_file, $ index_title, $ index_describe );Fputs ($ fp, "$ count found ");Fputs ($ fp, "query date: $ dte_createdrn ");Fputs ($ fp ,"
Rn ");Fputs ($ fp, $ index_data );Fputs ($ fp ,"
");Fclose ($ fp );Echo "Click here to view the new file index";}*/If (strlen ($ index_file )! = 0 ){$ In_file = "$ index_file ";$ Index_file = "\ index \". $ index_file;}Else$ In_file = "temp.html ";$ Fp = indexfile ($ index_file, $ index_title, $ index_describe );Fputs ($ fp, "$ count found ");Fputs ($ fp, "query date: $ dte_createdrn ");Fputs ($ fp ,"
Rn ");Fputs ($ fp, $ index_data );Fputs ($ fp ,"
");Fclose ($ fp );// Echo "Click here to view the new file index";Header ("location: $ index_url $ in_file "); // Echo "the index file is $ index_file ";Echo"Return ";Endif;?>