//This program is specially designed to parse the articles of National People’s Congress copy materials into the database. //Editor: Kong Xiuxiang. Date: 2001/4/10 switch($position) { default: session_start(); if (!isset($auth_passed)) { echo "This function is only authorized Only users can use it. "; return -1; }
if(isset($u_name)) { session_name($u_name);
//echo "
".session_name().": This program will serve you wholeheartedly.
n"; //echo ""; }
?>
Article added to database < ;/HEAD>
ACTION= "" METHOD = "POST">
< TD rowspan=5>Query description
File Name< TD>
Index file name
< ;INPUT NAME = "index_file" TYPE = "text" VALUE="" SIZE = "30">
Index Title
Article Category
break; case "process": session_start(); require "config.php3";
$UploadAction=0; $index_path="\index\ "; $added=0; //Mark whether the index file already exists. $die=0; //Exit the loop mark when encountering an abnormal situation. $data_exist=0; //The measurement of the article to be added already exists $data_insert=0; //The measurement of the newly added article $repeat=0; //Is it a duplicate? $TimeLimit=0; //Set the timeout limit. The default time is 30 seconds. When set to 0, there is no time limit. set_time_limit($TimeLimit);
//$UploadPath = AddSlashes(dirname ($PATH_TRANSLATED)); $FileName = $UploadPath.$UploadFile_name; //Upload file name //If(($UploadFile != "none")&&($UploadFile != "")) If(($UploadFile == "none")||($UploadFile == "")){ $page=$PHP_SELF; xueroom_error_exit("The file name cannot be empty, or the file is not uploaded Success. ",$page); } //$file_data=file($UploadFile); $link=@MYSQL_CONNECT($hostname,$dbusername,$dbpassword) OR DIE("Cannot connect Database! "); @mysql_select_db("$dbname") or die("Cannot select database!");
$patterne="/[s*document number s*](.+) n/U"; //Document number $patternf="/[Original source](.+)n/U"; //Original source $patterng="/[Original issue number](. +)n/U"; //Original issue number $patternh="/[Divided into s*category s*number](.+)n/U"; //Category number $patternb=" /【Copy issue number】(.+)n/U"; //Copy issue number
//$patternc="/.*s*【Title】(.+)n【.*/ Us"; //The title originally did not add n, but when I encountered "Small Sentence (d0a1bee4)", a1be happened to be the internal code of "[". 2001/3/13
//$patternc="/[Title](.+)n[.*/Us"; //Title originally did not add n, but encountered "subsentence ( d0a1bee4)" where a1be happens to be the internal code of "[". 2001/3/13 $patternc="/[s*subscript s*title s*](.+)n【.*/Us"; //The title originally did not add n, but when I encountered "subject" (d0a1bee4)" where a1be happens to be the internal code of "[". 2001/3/13 $patternd="/[s*authored by s* by s*](.+)n/U"; //authored by $patterna="/(.+【s* Positive s*text s*】)(.+)$/Us"; //Leave a [ as the end mark of the title bar. $pattern11="/[About the author](.+)[.*/Us";// $pattern12="/[Abstract](.+)[.*/Us";//
$fp_o=fopen("$UploadFile",'r'); $data=fread($fp_o,filesize($UploadFile)); //File reading Character variable fclose($fp_o); $poem_array=preg_split("/ns+ns+ns+/",$data); $replacement[0]="/(Note.*)$ /s"; // "Note" should be written, otherwise "(upper/lower)" will also be deleted. $replacement[1]="/(Note.*)ns*/s"; //Designed for an article by Ma Qingzhu. There is a subtitle after the note. //echo$poem_array[1]; $s=sizeof($poem_array); for($i=0;$i<$s;$i++){ //For a web page All Tang poems are operated. //for($i=0;$i<2;$i++){ //Perform operations on all Tang poems in a web page. $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]; //复印期号 else $date_rep=""; if(preg_match($patternc,$data,$matchesc,PREG_SET_ORDER)){ $artical_title=trim($matchesc[1]); //标题 $artical_title=preg_replace($replacement,"",$artical_title); // echo $artical_title." "; } else $artical_title=""; if(preg_match($patternd,$data,$matchesd,PREG_SET_ORDER)) $artical_author=trim($matchesd[1]); //作者 else $artical_author="";
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn