国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

人大復(fù)印資料處理程序_輸入篇

2024-05-04 23:01:17
字體:
供稿:網(wǎng)友
<?
//本程序是為解析人大復(fù)印資料的文章到數(shù)據(jù)庫專用。
//編者:孔秀祥。日期:2001/4/10
switch($position) {
    default:
session_start();
if (!isset($auth_passed)) {
echo "本功能只有授權(quán)用戶才能使用。";
return -1;
}

if(isset($u_name)) {
  session_name($u_name);

//echo "<center><font color='red'>".session_name().":本程序?qū)⒔哒\為您服務(wù)。</font></center>/n";
//echo "<hr>";
}

?>
<html><head>
<title>文章加入數(shù)據(jù)庫 </title>
</head>
<body><table><center>
<form enctype= "multipart/form-data" name = "submitform"
action= "<? $php_self ?>" method = "post">
<input type= "hidden" name = "max_file_size" value ="20000000">
<!--input type= "hidden" name = "uploadaction" value = "1"-->
<input type= "hidden" name = "position" value = "process">
<tr><td>文件名<td><input name = "uploadfile" type = "file" value="" size = "30"></tr>
<tr><td>索引文件名<td><input name = "index_file" type = "text" value="" size = "30"></td></tr>
<tr><td>索引標(biāo)題<td><input name = "index_title" type = "text" value="學(xué)而齋資料" size = "30"></td></tr>

<tr><td rowspan=5>查詢說明</td>
<!--/tr><tr-->
<td rowspan=5><textarea wrap=on rows="5" cols="30" name = "index_describe" size = "250">
人大復(fù)印資料(1985-1989)根據(jù)任意詞查詢,任意詞=
</textarea></td>
</tr>

<td>文章分類</td>
</tr>
<tr><td>
<select size="1" name="catalog" type = "int" default=11>
?<option selected value="11">語言理論</option>
?<option value="12">語法學(xué)</option>
?<option value="13">語義學(xué)</option>
?<option value="14">語用學(xué)</option>
?<option value="15">修辭學(xué) </option>
?<option value="16">古代漢語</option>
?<option value="21">歷史學(xué)</option>
?<option value="31">中國哲學(xué)</option>
?<option value="41">其他</option>
</select>
</tr>

<tr><td align=center>
<input name = "submit" value = "提交" type = "submit">
<td><input name = "reset" value = "重置" type = "reset">
</td></tr>
</form></center></table></body>

</html>
<?

          break;
    case "process":
session_start();
require "config.php3";

$uploadaction=0;
$index_path="http://index//";
$added=0; //索引文件是否已經(jīng)存在的標(biāo)記。
$die=0; //碰到異常情況退出循環(huán)標(biāo)記。
$data_exist=0;  //要加入的文章已經(jīng)存在的計(jì)量
$data_insert=0;   //新加入文章的計(jì)量
$repeat=0;      //是不是重復(fù)了。
$timelimit=0; //設(shè)置超時限制時間缺省時間為 30秒設(shè)置為0時為不限時
set_time_limit($timelimit);

//$uploadpath = addslashes(dirname($path_translated));
$filename = $uploadpath.$uploadfile_name; //上載文件名
//if(($uploadfile != "none")&&($uploadfile != ""))
if(($uploadfile =="none")||($uploadfile == "")){
    $page=$php_self;
    xueroom_error_exit("文件名不能為空,或者文件沒有上傳成功。",$page);
}
//$file_data=file($uploadfile);
$[email protected]_connect($hostname,$dbusername,$dbpassword) or die("不能連接數(shù)據(jù)庫!");
@mysql_select_db("$dbname") or die("不能選擇數(shù)據(jù)庫!");

$patterne="/【/s*文獻(xiàn)號/s*】(.+)/n/u";  //文獻(xiàn)號
$patternf="/【原文出處】(.+)/n/u";  //原文出處
$patterng="/【原刊期號】(.+)/n/u";  //原刊期號
$patternh="/【分/s*類/s*號】(.+)/n/u";  //分 類 號
$patternb="/【復(fù)印期號】(.+)/n/u";  //復(fù)印期號

//$patternc="/.*/s*【 標(biāo)  題 】(.+)/n【.*/us";  //標(biāo)  題  本來不加/n,但碰到“小句(d0a1bee4)”其中的a1be正好是“【”的內(nèi)碼。2001/3/13

//$patternc="/【 標(biāo)  題 】(.+)/n【.*/us";  //標(biāo)  題  本來不加/n,但碰到“小句(d0a1bee4)”其中的a1be正好是“【”的內(nèi)碼。2001/3/13
$patternc="/【/s*標(biāo)/s*題/s*】(.+)/n【.*/us";  //標(biāo)  題  本來不加/n,但碰到“小句(d0a1bee4)”其中的a1be正好是“【”的內(nèi)碼。2001/3/13
$patternd="/【/s*作/s*者/s*】(.+)/n/u";  //作  者
$patterna="/(.+【/s*正/s*文/s*】)(.+)$/us";  //留下一個【,作為標(biāo)題欄的結(jié)束標(biāo)記。
$pattern11="/【作者簡介】(.+)【.*/us";//
$pattern12="/【內(nèi)容提要】(.+)【.*/us";//



$fp_o=fopen("$uploadfile",'r');
$data=fread($fp_o,filesize($uploadfile));  //文件讀入字符變量
fclose($fp_o);
$poem_array=preg_split("http://n/s+/n/s+/n/s+/",$data);
$replacement[0]="/(注.*)$/s";    //應(yīng)該寫上“注”,否則把“(上/下)”也刪了。
$replacement[1]="/(注.*)/n/s*/s";  //為馬慶株的一篇文章而設(shè)。注后還有副題。
//echo$poem_array[1];
$s=sizeof($poem_array);
for($i=0;$i<$s;$i++){  //對一個網(wǎng)頁內(nèi)的所有唐詩進(jìn)行操作。
//for($i=0;$i<2;$i++){  //對一個網(wǎng)頁內(nèi)的所有唐詩進(jìn)行操作。
    $t_data=$poem_array[$i];
//    if(preg_match($pattern,$data,$matches,preg_set_order)){
    if(preg_match($patterna,$t_data,$matchesa,preg_set_order)){
        $artical_data=$matchesa[2];   //正文
        $data=$matchesa[1];   //文章頭
        if(preg_match($patternb,$data,$matchesb,preg_set_order))
            $date_rep=$matchesb[1];     //復(fù)印期號
            else
            $date_rep="";
        if(preg_match($patternc,$data,$matchesc,preg_set_order)){
            $artical_title=trim($matchesc[1]);   //標(biāo)題
            $artical_title=preg_replace($replacement,"",$artical_title);
//            echo $artical_title."<br>";
            }
            else
            $artical_title="";
        if(preg_match($patternd,$data,$matchesd,preg_set_order))
            $artical_author=trim($matchesd[1]);   //作者
            else
            $artical_author="";

        if(preg_match($patterne,$data,$matchese,preg_set_order)){
            $resource_id=trim($matchese[1]);   //人大編號
//            echo $resource_id."<br>";
            }
            else
            $resource_id="";
        if(preg_match($patternf,$data,$matchesf,preg_set_order))
            $origin_periodical=trim($matchesf[1]);   //期刊
            else
            $origin_periodical="";
        if(preg_match($patterng,$data,$matchesg,preg_set_order))
            $date_temp=$matchesg[1];   //出版日期
            else
            $date_temp="";
        if(preg_match($patternh,$data,$matchesh,preg_set_order))
            $artical_type=trim($matchesh[1]);   //文章分類
            else
            $artical_type="";
/*
        if(preg_match($pattern11,$data,$matchesd,preg_set_order))
            $author_brif=$matchesd[1];   //作者簡介
            else
            $author_brif="";
*/
        if(preg_match($pattern12,$data,$matches12,preg_set_order))
            $content_brif=$matches12[1];   //內(nèi)容提要
            else
            $content_brif="";
//        echo$data;
//echo $artical_title;
/*         
        echo $resource_id."<br>";
        echo $origin_periodical."<br>";
        echo $artical_title."<br>";
        echo $artical_author."<br>";
*/
//    echo $date_rep."<br>";     
     if(($artical_title=="")||($resource_id=="")){
         $a=$i+1;
              echo "標(biāo)題或人大編號為空,不合法。第 $a 篇沒有加入數(shù)據(jù)庫<br>";
              $die=1;
              //break;
      }
    else{
          if(strlen(trim(substr($date_temp,6,2)))!=0){
                  $date_pub=substr($date_temp,0,4)."-".substr($date_temp,4,2).substr($date_temp,6,2)." 00:00:00";
            }
           else{
                 $date_pub=substr($date_temp,0,4)."-".substr($date_temp,4,2)."-01 01:01:01";
                         //在日期的數(shù)字一定要有效,否則被置零。
//                         $date_pub=substr($date_temp,0,4)."-".substr($date_temp,4,2);
              }         //如果原文發(fā)表在報紙上,則有日期

    //    $artical_title=preg_replace($pattern91,"",$artical_title);
        $origin_periodical=addslashes($origin_periodical);
        $artical_title=addslashes($artical_title);
        $date_reprinted=substr($date_rep,0,4)."-".substr($date_rep,4,2)."-01 01:01:01";
        if($content_brif)
            $artical_data="$content_brif /r/n $artical_data";
         
             $artical_data=addslashes($artical_data);
             $artical__size=strlen($artical_data);
             $resource_id=trim($resource_id);
             $query = "insert into artical (resource_id, origin_periodical,date_pub, artical_author, artical_title, artical_data, artical_type,artical__size, date_reprinted,catalog) values ('$resource_id', '$origin_periodical','$date_pub', '$artical_author', '$artical_title', '$artical_data', '$artical_type','$artical__size', '$date_reprinted',$catalog)";
             $q="select artical_id,resource_id,artical_title,artical_author,artical_type from artical where resource_id=/"$resource_id/"";
             $r = @mysql_query($q);
//             $[email protected]_fetch_row($r);
//             echo "$artical_type,,".$count[4]."<br>";
        while($count=mysql_fetch_array($r)){  //重復(fù)的號碼可能有多個,真正重復(fù)的不一定是第一個找到的。所以要用循環(huán)來找。2001/3/16
                                              //為了找到個理由,我花的代價可是不小。
            if($artical_type==$count[4]&&$artical_author==$count[3]){
                      $data_exist+=1;
                      $id=$count[0];
                      $title=$count[2];
                      $author=$count[3];
                $repeat=1;
                break;
            }
        }
              if($repeat){
            $f_data.="<tr><td><a href=".$dataurl."readfile.php3?artical_id=$id>$title</a><td>作者:$author </tr>/r/n";
            $repeat=0;
              }
           else{
            
                $result = @mysql_query($query);
                if($result){
                       $data_insert+=1;
                       $id= mysql_insert_id();
                       $f_data.="<tr><td><a href=".$dataurl."readfile.php3?artical_id=$id>$artical_title</a><td>作者:$artical_author</tr>/r/n";
              }
            else{
                echo $data;
                echo'數(shù)據(jù)寫入失敗<br>';
                 }//if($result)
        }//if(strlen($count)!=0){  //文章是否已經(jīng)存在。

    }//if(strlen($artical_title)==0){

    }//if(preg_match($patterna,$t_data,$matchesa,preg_set_order)){
}//for()

//下面為結(jié)束處理。
set_time_limit(30);
mysql_close($link);
$dte_created=date('y-m-d h:i:s');
$total=$data_exist+$data_insert;

if($index_title==""){
$index_title="學(xué)而齋資料";
}
$index_title=$index_title."_".$data_search;

$html_header="<html><head><title>$index_title</title></head><body>";
$html_header.="<h5>$index_title</h5>/r/n";
$dte_created=date('y-m-d h:i:s');
$html_header.="<font color='maroon' face='楷體' size=1>$index_describe 發(fā)現(xiàn)了 $total 條/上載日期:$dte_created</font><hr>/r/n";
$html_header.="<table>/r/n";
$data=$html_header.$f_data;
$data.="<table></body></html>";
/*
if(strlen($index_file)==0){
header("content-type: text/html");
   echo $data;
   }
   else
   {
*/
if(strlen($index_file)!=0){
     $in_file="$index_file";
    $index_file=$index_path.$in_file;
  }
else
       $in_file="temp.html";

$fp=indexfile($index_file,$index_title,$index_describe);
fputs($fp, "發(fā)現(xiàn)了 $total 條");
fputs($fp, "查詢?nèi)掌冢?#36;dte_created</font><hr>/r/n");
fputs($fp,"<table>/r/n");
fputs($fp, $f_data);
fputs($fp, "<table></body></html>");
fclose($fp);
echo "<html><head><title>文件提取</title></head><body>";

if($added){  //如果索引文件存在。$added是一個全局變量。
    echo "索引文件".$in_file."已經(jīng)存在,新索引已經(jīng)加入到文件的最后。<br>";
    //  echo "請看<a href=$index_url$in_file>".$in_file.'</a>的最后'.$total.'條。<br>';
      }

else{
     //將新索引文件寫入總索引文件。
     $total_index=$index_path."k_index.html";
     $fp_i=fopen($total_index,'a+');
     $file_link="<a href=$index_url$in_file>$index_describe</a><br>/r/n";
     fputs($fp_i, $file_link);
     fclose($fp_i);
}//if($added)
echo"點(diǎn)<a href=$index_url$in_file>這里</a>看新加入的文件索引<br>";

//}//if(strlen($index_file)==0){
  
if($data_exist>0)
     echo "重復(fù)的文章共".$data_exist."篇。<br>";
if($data_insert>0)
    echo "新加入的文章共".$data_insert."篇。<hr>";
$total=$data_exist+$data_insert;
echo"上傳文件".$uploadfile_name."共有文章".$total."篇。";
echo"<br><a href = $php_self>返回 </a>";
echo"</body></html>";
break;
  }
?> 
  • 網(wǎng)站運(yùn)營seo文章大全
  • 提供全面的站長運(yùn)營經(jīng)驗(yàn)及seo技術(shù)!
  • 發(fā)表評論 共有條評論
    用戶名: 密碼:
    驗(yàn)證碼: 匿名發(fā)表
    主站蜘蛛池模板: 柞水县| 梨树县| 张家口市| 舟曲县| 西乌珠穆沁旗| 普陀区| 常山县| 盐津县| 弋阳县| 扶沟县| 威远县| 荃湾区| 肇东市| 东山县| 广河县| 平遥县| 彩票| 溧水县| 夹江县| 忻城县| 瓦房店市| 毕节市| 昭苏县| 盐池县| 曲靖市| 象州县| 盈江县| 襄垣县| 库伦旗| 鄂温| 阆中市| 桦川县| 防城港市| 河北区| 乌苏市| 白城市| 酒泉市| 高碑店市| 栾川县| 商水县| 万盛区|