人大影印資料處理程式_查詢篇

NO IMAGE

<?
//本程式為一個搜尋,目前設計服務於文章庫。
//編者:孔秀祥。日期:2001/4/10
if(!$UploadAction):
require "config.php3";
if(!isset($table)){
//$table="artical";
}
/*
[email protected]_CONNECT($hostname,$dbusername,$dbpassword) OR DIE("不能連線資料庫!");
@mysql_select_db("$dbname") or die("不能選擇資料庫!");
$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>資料庫搜尋 </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=726cc5>
<!–tr><td colspan=2 bgcolor=726cc5–>
<font color=white face=Arial,Helvetica size=2>
<CENTER>
本程式執行較費時間,需要耐心等待。</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>查詢專案
<tr><td colspan=2 align=center><input type="radio" name=a_data value="data" checked>文章內容
<input type="radio" name=a_data value="title">文章標題
<input type="radio" name=a_data value="author">文章作者
<input type="radio" name=a_data value="month" >期刊名
<!–input type="radio" name=a_data value="type" >分類號<BR–>
<TR><TD>搜尋內容<TD><INPUT NAME = "data_search" TYPE = "text" VALUE="" SIZE = "30"></TD>
<TR><TD>索引檔名<TD><INPUT NAME = "index_file" TYPE = "text" VALUE="" SIZE = "30"></TD>
<TR><TD>索引標題<TD><INPUT NAME = "index_title" TYPE = "text" VALUE="" SIZE = "30"></TD>
<!–TR><TD>從第<INPUT NAME = "s_id" TYPE = "text" VALUE="1" SIZE = "4"><td>
開始的<INPUT NAME = "step" TYPE = "text" VALUE="100" SIZE = "4">條,共有<? echo $r_count ?>條記錄。</TD></TR–>
<TR><TD>文章分類</TD>
<TD>
<SELECT size="1" name="catalog" TYPE = "int">
?<OPTION selected value="11">語言理論</OPTION>
<OPTION value="21">歷史學</OPTION>
<OPTION value="31">中國哲學</OPTION>
<OPTION value="41">其他</OPTION>
?<!–OPTION selected value="11">語言理論</OPTION–>
</SELECT>
</TR>
<TR><TD colspan=3 align=center>
<INPUT NAME = "submit" VALUE = "提交" TYPE = "submit">
<INPUT NAME = "reset" VALUE = "重置" 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; /*設定超時限制時間預設時間為 30秒設定為0時為不限時 */
set_time_limit($TimeLimit);

if($data_search==""){
//做全庫的索引
header("location:\progs\data_index.php3");
//$msg="搜尋內容不能為空。";
//xueroom_error_exit($msg,$PHP_SELF);
}

[email protected]_CONNECT($hostname,$dbusername,$dbpassword) OR DIE("不能連線資料庫!");
@mysql_select_db("$dbname") or die("不能選擇資料庫!");
//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 [email protected] mysql_query($q);

if(!$result){
    $msg="沒有符合要求的記錄。";
    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)) //可以用於尋找單個漢字。
//  if(strpos($data,$data_search)){  //大於一個漢字時採用本判斷式,速度較快。
      $index_data.="<TR><TD><a href=".$dataurl."$prog?$sid=$id>$title</a><TD>作者:$author </TR>";
      $count ;
  //fputs($fp, "<TR><TD><a href=".$dataurl."readfile.php3?artical_id=$id>$title</a><TD>作者:$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><head><title>$index_title</title></head><body>";
$html_header.="<h5>$index_title</h5>rn";
$dte_created=date(‘Y-m-d H:i:s’);
$html_header.="<font color=’Maroon’ face=’楷體’ size=1>$index_describe 發現了 $count 條/查詢日期:$dte_created</font><hr>rn";
$html_header.="<table>rn";
$data=$html_header.$index_data;
$data.="<TABLE></body></html>";
/*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 條");
fputs($fp, "查詢日期:$dte_created</font><hr>rn");
fputs($fp,"<table>rn");
fputs($fp, $index_data);
fputs($fp, "<TABLE></body></html>");
fclose($fp);
echo"點<a href=$index_url$in_file>這裡</a>看新加入的檔案索引<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 條");
fputs($fp, "查詢日期:$dte_created</font><hr>rn");
fputs($fp,"<table>rn");
fputs($fp, $index_data);
fputs($fp, "<TABLE></body></html>");
fclose($fp);

//    echo"點<a href=$index_url$in_file>這裡</a>看新加入的檔案索引<BR>";
header("location:$index_url$in_file");

    
//echo"索引檔案為 $index_file";
echo"<BR><A HREF = $PHP_SELF>返回 </A>";

endif;
?>