Table of Contents
$index_title
Home Backend Development PHP Tutorial 人大复印资料处理程序_输入篇_PHP

人大复印资料处理程序_输入篇_PHP

Jun 01, 2016 pm 12:29 PM
data if deal with copy program material enter


//本程序是为解析人大复印资料的文章到数据库专用。
//编者:孔秀祥。日期:2001/4/10
switch($position) {
default:
session_start();
if (!isset($auth_passed)) {
echo "本功能只有授权用户才能使用。";
return -1;
}

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

//echo "
".session_name().":本程序将竭诚为您服务。
\n";
//echo "
";
}

?>

文章加入数据库


ACTION= " $PHP_SELF ?>" METHOD = "POST">

















文件名
索引文件名
索引标题
查询说明
文章分类










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

$UploadAction=0;
$index_path="\\index\\";
$added=0; //索引文件是否已经存在的标记。
$die=0; //碰到异常情况退出循环标记。
$data_exist=0; //要加入的文章已经存在的计量
$data_insert=0; //新加入文章的计量
$repeat=0; //是不是重复了。
$TimeLimit=0; //设置超时限制时间缺省时间为 30秒设置为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);
$link=@MYSQL_CONNECT($hostname,$dbusername,$dbpassword) OR DIE("不能连接数据库!");
@mysql_select_db("$dbname") or die("不能选择数据库!");

$patterne="/【\s*文献号\s*】(. )\n/U"; //文献号
$patternf="/【原文出处】(. )\n/U"; //原文出处
$patterng="/【原刊期号】(. )\n/U"; //原刊期号
$patternh="/【分\s*类\s*号】(. )\n/U"; //分 类 号
$patternb="/【复印期号】(. )\n/U"; //复印期号

//$patternc="/.*\s*【 标 题 】(. )\n【.*/Us"; //标 题 本来不加\n,但碰到“小句(d0a1bee4)”其中的a1be正好是“【”的内码。2001/3/13

//$patternc="/【 标 题 】(. )\n【.*/Us"; //标 题 本来不加\n,但碰到“小句(d0a1bee4)”其中的a1be正好是“【”的内码。2001/3/13
$patternc="/【\s*标\s*题\s*】(. )\n【.*/Us"; //标 题 本来不加\n,但碰到“小句(d0a1bee4)”其中的a1be正好是“【”的内码。2001/3/13
$patternd="/【\s*作\s*者\s*】(. )\n/U"; //作 者
$patterna="/(. 【\s*正\s*文\s*】)(. )$/Us"; //留下一个【,作为标题栏的结束标记。
$pattern11="/【作者简介】(. )【.*/Us";//
$pattern12="/【内容提要】(. )【.*/Us";//



$fp_o=fopen("$UploadFile",'r');
$data=fread($fp_o,filesize($UploadFile)); //文件读入字符变量
fclose($fp_o);
$poem_array=preg_split("/\n\s \n\s \n\s /",$data);
$replacement[0]="/(注.*)$/s"; //应该写上“注”,否则把“(上/下)”也删了。
$replacement[1]="/(注.*)\n\s*/s"; //为马庆株的一篇文章而设。注后还有副题。
//echo$poem_array[1];
$s=sizeof($poem_array);
for($i=0;$i //for($i=0;$i $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="";

if(preg_match($patterne,$data,$matchese,PREG_SET_ORDER)){
$resource_id=trim($matchese[1]); //人大编号
// echo $resource_id."
";
}
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]; //内容提要
else
$content_brif="";
// echo$data;
//echo $artical_title;
/*
echo $resource_id."
";
echo $origin_periodical."
";
echo $artical_title."
";
echo $artical_author."
";
*/
// echo $date_rep."
";
if(($artical_title=="")||($resource_id=="")){
$a=$i 1;
echo "标题或人大编号为空,不合法。第 $a 篇没有加入数据库
";
$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";
//在日期的数字一定要有效,否则被置零。
// $date_pub=substr($date_temp,0,4)."-".substr($date_temp,4,2);
} //如果原文发表在报纸上,则有日期

// $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);
// $count=@mysql_fetch_row($r);
// echo "$artical_type,,".$count[4]."
";
while($count=mysql_fetch_array($r)){ //重复的号码可能有多个,真正重复的不一定是第一个找到的。所以要用循环来找。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.=" $title 作者:$author \r\n";
$repeat=0;
}
else{

$result = @mysql_query($query);
if($result){
$data_insert =1;
$id= mysql_insert_id();
$f_data.=" $artical_title 作者:$artical_author \r\n";
}
else{
echo $data;
echo'数据写入失败
';
}//if($result)
}//if(strlen($count)!=0){ //文章是否已经存在。

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

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

//下面为结束处理。
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="学而斋资料";
}
$index_title=$index_title."_".$data_search;

$html_header="$index_title";
$html_header.="
$index_title
\r\n";
$dte_created=date('Y-m-d H:i:s');
$html_header.="$index_describe 发现了 $total 条/上载日期:$dte_created
\r\n";
$html_header.="\r\n";
$data=$html_header.$f_data;
$data.="
";
/*
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, "发现了 $total 条");
fputs($fp, "查询日期:$dte_created
\r\n");
fputs($fp,"
\r\n");
fputs($fp, $f_data);
fputs($fp, "
Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to make Google Maps the default map in iPhone How to make Google Maps the default map in iPhone Apr 17, 2024 pm 07:34 PM

The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

Disabling Win11 Input Experience Guide Disabling Win11 Input Experience Guide Dec 27, 2023 am 11:07 AM

Recently, many Win11 users have encountered the problem that the input experience dialog box always flickers and cannot be turned off. This is actually caused by the default system services and components of Win11. We need to disable the relevant services first, and then disable the input experience service. Solved, let’s try it out together. How to turn off the input experience in win11: First step, right-click the start menu and open "Task Manager". Second step, find the three processes "CTF Loader", "MicrosoftIME" and "Service Host: Textinput Management Service" in order, right-click "End Task" "The third step, open the start menu, search and open "Services" at the top. The fourth step, find "Textinp" in it

Windows input encounters hang or high memory usage [Fix] Windows input encounters hang or high memory usage [Fix] Feb 19, 2024 pm 10:48 PM

The Windows input experience is a key system service responsible for processing user input from various human interface devices. It starts automatically at system startup and runs in the background. However, sometimes this service may automatically hang or occupy too much memory, resulting in reduced system performance. Therefore, it is crucial to monitor and manage this process in a timely manner to ensure system efficiency and stability. In this article, we will share how to fix issues where the Windows input experience hangs or causes high memory usage. The Windows Input Experience Service does not have a user interface, but it is closely related to handling basic system tasks and functions related to input devices. Its role is to help the Windows system understand every input entered by the user.

The operation process of WIN10 service host occupying too much CPU The operation process of WIN10 service host occupying too much CPU Mar 27, 2024 pm 02:41 PM

1. First, we right-click the blank space of the taskbar and select the [Task Manager] option, or right-click the start logo, and then select the [Task Manager] option. 2. In the opened Task Manager interface, we click the [Services] tab on the far right. 3. In the opened [Service] tab, click the [Open Service] option below. 4. In the [Services] window that opens, right-click the [InternetConnectionSharing(ICS)] service, and then select the [Properties] option. 5. In the properties window that opens, change [Open with] to [Disabled], click [Apply] and then click [OK]. 6. Click the start logo, then click the shutdown button, select [Restart], and complete the computer restart.

How to write if in c language to judge multiple conditions How to write if in c language to judge multiple conditions Mar 25, 2024 pm 03:24 PM

In C language, if statement is usually used to execute a specific block of code based on a single condition. However, multiple conditions can be combined to make a determination using logical operators such as &&, ||, and !. Including using logical AND (&&) to judge multiple conditions, using logical OR (||) to judge at least one condition, using logical NOT (!) to judge the negation of a single condition, as well as nesting if statements and using parentheses to clarify priority.

Clock app missing in iPhone: How to fix it Clock app missing in iPhone: How to fix it May 03, 2024 pm 09:19 PM

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

Can't allow access to camera and microphone in iPhone Can't allow access to camera and microphone in iPhone Apr 23, 2024 am 11:13 AM

Are you getting "Unable to allow access to camera and microphone" when trying to use the app? Typically, you grant camera and microphone permissions to specific people on a need-to-provide basis. However, if you deny permission, the camera and microphone will not work and will display this error message instead. Solving this problem is very basic and you can do it in a minute or two. Fix 1 – Provide Camera, Microphone Permissions You can provide the necessary camera and microphone permissions directly in settings. Step 1 – Go to the Settings tab. Step 2 – Open the Privacy & Security panel. Step 3 – Turn on the “Camera” permission there. Step 4 – Inside, you will find a list of apps that have requested permission for your phone’s camera. Step 5 – Open the “Camera” of the specified app

A quick guide to CSV file manipulation A quick guide to CSV file manipulation Dec 26, 2023 pm 02:23 PM

Quickly learn how to open and process CSV format files. With the continuous development of data analysis and processing, CSV format has become one of the widely used file formats. A CSV file is a simple and easy-to-read text file with different data fields separated by commas. Whether in academic research, business analysis or data processing, we often encounter situations where we need to open and process CSV files. The following guide will show you how to quickly learn to open and process CSV format files. Step 1: Understand the CSV file format First,

See all articles