<?
// 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)"];
*/
?>
<HTML> <HEAD> <TITLE> database search </TITLE>
</HEAD>
<BODY> <table align = center cellpadding = "0" cellspacing = "0" width = "420" style = "border-style: outset; border-bottom-width: thin; border-left-width: thin; border-right-width: thin; border-top-width: thin; border-color: # fefefe; ">
<TH colspan = 2 bgcolor = required cc5>
<! -- Tr> <td colspan = 2 bgcolor = Invalid cc5 -->
<Font color = white face = Arial, Helvetica size = 2>
<CENTER>
It takes a long time to run the program. </TH>
<Form enctype = "multipart/form-data" NAME = "SubmitForm"
ACTION = "<? $ PHP_SELF?> "METHOD =" POST ">
<! -- Input type = "hidden" NAME = "MAX_FILE_SIZE" VALUE = "2500000" -->
<Input type = "hidden" NAME = "UploadAction" VALUE = "1">
<Input type = "hidden" NAME = "table" VALUE = "<? Echo $ table;?> ">
<Input type = "hidden" name = table value = "artical">
<Tr border = 1> <td colspan = 2 align = center> query a project
<Tr> <td colspan = 2 align = center> <input type = "radio" name = a_data value = "data" checked> content
<Input type = "radio" name = a_data value = "title"> Article title
<Input type = "radio" name = a_data value = "author"> author
<Input type = "radio" name = a_data value = "month"> JOURNAL name
<! -- Input type = "radio" name = a_data value = "type"> classification number <BR -->
<TR> <TD> search content <TD> <input name = "data_search" TYPE = "text" VALUE = "" SIZE = "30"> </TD>
<TR> <TD> index file NAME <TD> <input name = "index_file" TYPE = "text" VALUE = "" SIZE = "30"> </TD>
<TR> <TD> index title <TD> <input name = "index_title" TYPE = "text" VALUE = "" SIZE = "30"> </TD>
<! -- TR> <TD> from the <input name = "s_id" TYPE = "text" VALUE = "1" SIZE = "4"> <td>
<Input name = "step" TYPE = "text" VALUE = "100" SIZE = "4"> total <? Echo $ r_count?> Records. </TD> </TR -->
<TR> <TD> document Category </TD>
<TD>
<SELECT size = "1" name = "catalog" TYPE = "int">
? <OPTION selected value = "11"> language theory </OPTION>
<OPTION value = "21"> history </OPTION>
<OPTION value = "31"> Chinese Philosophy </OPTION>
<OPTION value = "41"> others </OPTION>
? <! -- OPTION selected value = "11"> language theory </OPTION -->
</SELECT>
</TR>
<TR> <TD colspan = 3 align = center>
<Input name = "submit" VALUE = "submit" TYPE = "submit">
<Input name = "reset" VALUE = "reset" TYPE = "reset"> </TD>
</TD> </TR>
</FORM> </CENTER> </TABLE> </BODY>
</HTML>
<?
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. = "<TR> <TD> <a href =". $ dataurl. "$ prog? $ Sid = $ id >$ title </a> <TD> author: $ author </TR> ";
$ Count ++;
// Fputs ($ fp, "<TR> <TD> <a href =". $ dataurl. "readfile. php3? Artical_id = $ id >$ title </a> <TD> author: $ author </TR> ");
//}
}
}
@ 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 = "$ Html_header. = "$ Dte_created = date ('Y-m-d H: I: s ');
$ Html_header. = "<font color = 'maroon' face = 'body' size = 1> $ index_describe found $ count/query Date: $ dte_created </font> $ Html_header. = "<table> rn ";
$ Data = $ html_header. $ index_data;
$ Data. = "<TABLE> </body> /* 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_created </font> Fputs ($ fp, "<table> rn ");
Fputs ($ fp, $ index_data );
Fputs ($ fp, "<TABLE> </body> Fclose ($ fp );
Echo "Click <a href = $ index_url $ in_file> here </a> to view the new file index <BR> ";
}
*/
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_created </font> Fputs ($ fp, "<table> rn ");
Fputs ($ fp, $ index_data );
Fputs ($ fp, "<TABLE> </body> Fclose ($ fp );
// Echo "Click <a href = $ index_url $ in_file> here </a> to view the new file index <BR> ";
Header ("location: $ index_url $ in_file ");
// Echo "the index file is $ index_file ";
Echo "<BR> <a href = $ PHP_SELF> return </A> ";
Endif;
?>