ÈË´ó¸´Ó¡×ÊÁÏ´¦Àí³ÌÐò_ÊäÈëƪ

5年以前  |  阅读数:889 次  |  编程语言:PHP 

<?
//±¾³ÌÐoÊÇΪ½aÎoÈË´o¸´Ó¡×ÊÁϵÄÎÄÕµ½Êý¾Ý¿aרÓá£
//±aÕߣº¿×ÐaÏe¡£ÈÕÆÚ£º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().":±¾³ÌÐo½«½ß³ÏΪÄu*þÎñ¡£
\n";
//echo "
";
}

?>

ÎÄÕ¼ÓÈeÊý¾Ý¿a
ÎļþÃu
Ë÷ÒýÎļþÃu
Ë÷Òý±eÌa
²eѯ˵Ã÷
ÎÄÕÂ*ÖÀa
break; case "process":

session_start();
require "config.php3";

$UploadAction=0;
$index_path="\\index\\";
$added=0; //Ë÷ÒýÎļþÊÇñÒѾ­´aeÔڵıe¼Ç¡£
$die=0; //Åoµ½Òi³£Çe¿oÍ˳oÑ­»
±e¼Ç¡£
$data_exist=0; //Òª¼ÓÈeµÄÎÄÕÂÒѾ­´aeÔڵļÆÁ¿
$data_insert=0; //мÓÈeÎÄÕµļÆÁ¿
$repeat=0; //ÊDz»ÊÇÖظ´ÁË¡£
$TimeLimit=0; //ÉeÖó¬Ê±ÏÞÖÆʱ¼aȱʡʱ¼aΪ 30ÃeÉeÖÃΪ0ʱΪ²»ÏÞʱ
set_time_limit($TimeLimit);

//$UploadPath = AddSlashes(dirname($PATH_TRANSLATED));
$FileName = $UploadPath.$UploadFile_name; //ÉÏÔØÎļþÃu
//If(($UploadFile != "none")&&($UploadFile != ""))
If(($UploadFile =="none")||($UploadFile == "")){
$page=$PHP_SELF;
xueroom_error_exit("ÎļþÃu²»ÄÜΪ¿Õ£¬»oÕßÎļþûÓÐÉÏ´«³É¹¦¡£",$page);
}
//$file_data=file($UploadFile);
$link=@MYSQL_CONNECT($hostname,$dbusername,$dbpassword) OR DIE("²»ÄÜÁ¬½ÓÊý¾Ý¿a£¡");
@mysql_select_db("$dbname") or die("²»ÄÜÑ¡ÔñÊý¾Ý¿a£¡");

$patterne="/¡¾\sÎÄÏ׺Å\s¡¿(.+)\n/U"; //ÎÄÏ׺Å
$patternf="/¡¾Ô­Îijo´¦¡¿(.+)\n/U"; //Ô­Îijo´¦
$patterng="/¡¾Ô­¿¯Æںš¿(.+)\n/U"; //Ô­¿¯ÆÚºÅ
$patternh="/¡¾Ö\sÀa\sºÅ¡¿(.+)\n/U"; //Ö Àa ºÅ
$patternb="/¡¾¸´Ó¡Æںš¿(.+)\n/U"; //¸´Ó¡ÆÚºÅ

//$patternc="/.\s¡¾ ±e Ìa ¡¿(.+)\n¡¾.*/Us"; //±e Ìa ±¾À´²»¼Ó\n£¬µ«Åoµ½¡°Ð¡¾a(d0a1bee4)¡±ÆaÖеÄa1beÕýºÃÊÇ¡°¡¾¡±µÄÄÚÂe¡£2001/3/13

//$patternc="/¡¾ ±e Ìa ¡¿(.+)\n¡¾./Us"; //±e Ìa ±¾À´²»¼Ó\n£¬µ«Åoµ½¡°Ð¡¾a(d0a1bee4)¡±ÆaÖеÄa1beÕýºÃÊÇ¡°¡¾¡±µÄÄÚÂe¡£2001/3/13
$patternc="/¡¾\s
±e\sÌa\s¡¿(.+)\n¡¾./Us"; //±e Ìa ±¾À´²»¼Ó\n£¬µ«Åoµ½¡°Ð¡¾a(d0a1bee4)¡±ÆaÖеÄa1beÕýºÃÊÇ¡°¡¾¡±µÄÄÚÂe¡£2001/3/13
$patternd="/¡¾\s
×÷\sÕß\s¡¿(.+)\n/U"; //×÷ Õß
$patterna="/(.+¡¾\sÕý\sÎÄ\s¡¿)(.+)$/Us"; //ÁoÏÂÒ»¸o¡¾£¬×÷Ϊ±eÌaÀ¸µÄ½aÊø±e¼Ç¡£
$pattern11="/¡¾×÷Õß¼o½e¡¿(.+)¡¾.
/Us";//
$pattern12="/¡¾ÄÚÈÝÌaÒª¡¿(.+)¡¾.*/Us";//

$fp_o=fopen("$UploadFile",'r');
$data=fread($fp_o,filesize($UploadFile)); //Îļþ¶ÁÈe×Öu±aÁ¿
fclose($fp_o);
$poem_array=preg_split("/\n\s+\n\s+\n\s+/",$data);
$replacement[0]="/£¨×¢.
£(C)$/s"; //Ó¦¸ÃдÉÏ¡°×¢¡±£¬ñÔo°Ñ¡°£¨ÉÏ/Ï£(C)¡±Ò²É¾ÁË¡£
$replacement[1]="/£¨×¢.
£(C)\n\s/s"; //ΪÂiÇiÖeµÄһƪÎÄÕ¶øÉe¡£×¢ºo»¹Óи±Ìa¡£
//echo$poem_array[1];
$s=sizeof($poem_array);
for($i=0;$i<$s;$i++){ //¶ÔÒ»¸oÍøÒ³ÄÚµÄËuÓÐÌÆÊ«½øÐвÙ×÷¡£
//for($i=0;$i<2;$i++){ //¶ÔÒ»¸oÍøÒ³ÄÚµÄËuÓÐÌÆÊ«½øÐвÙ×÷¡£
$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]); //±eÌa
$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]);   //ÈË´o±aºÅ   

// 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]; //³o°aeÈÕÆÚ
else
$date_temp="";
if(preg_match($patternh,$data,$matchesh,PREG_SET_ORDER))
$artical_type=trim($matchesh[1]); //ÎÄÕÂÖÀa
else
$artical_type="";
/

if(preg_match($pattern11,$data,$matchesd,PREG_SET_ORDER))
$author_brif=$matchesd[1]; //×÷Õß¼o½e
else
$author_brif="";
/
if(preg_match($pattern12,$data,$matches12,PREG_SET_ORDER))
$content_brif=$matches12[1]; //ÄÚÈÝÌaÒª
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 "±eÌa»oÈË´o±aºÅΪ¿Õ£¬²»ºÏ
¨¡£µÚ $a ƪûÓмÓÈeÊý¾Ý¿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";
//ÔÚÈÕÆÚµÄÊý×ÖÒ»¶¨ÒªÓÐЧ£¬ñÔo±»ÖÃÁa¡£
// $date_pub=substr($date_temp,0,4)."-".substr($date_temp,4,2);
} //Èç¹uÔ­ÎÄ
¢±iÔÚ±¨Ö½ÉÏ£¬ÔoÓÐÈÕÆÚ

//    $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)){ //Öظ´µÄºÅÂe¿ÉÄÜÓжa¸o£¬ÕaeÕýÖظ´µÄ²»Ò»¶¨ÊǵÚÒ»¸oÕÒµ½µÄ¡£ËuÒÔÒªÓÃÑ­»*À´ÕÒ¡£2001/3/16
//ΪÁËÕÒµ½¸oÀiÓÉ£¬ÎÒ»¨µÄ´u¼Û¿ÉÊDz»Ð¡¡£
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.="<a href=".$dataurl."readfile.php3?artical_id=$id>$title×÷Õߣº$author \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'Êý¾ÝдÈeʧ°Ü<br>';   
             }//if($result)   
    }//if(strlen($count)!=0){  //ÎÄÕÂÊÇ*ñÒѾ­´aeÔÚ¡£   

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

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

}//for()

//ÏÂÃaeΪ½aÊø´¦Ài¡£
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=$indextitle."".$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 Ìo/ÉÏÔØÈÕÆÚ£º$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 Ìo");
fputs($fp, "²eѯÈÕÆÚ£º$dte_created


\r\n");
fputs($fp,"
\r\n");
fputs($fp, $f_data);
fputs($fp, "
");
fclose($fp);
echo "ÎļþÌaÈ¡";

if($added){ //Èç¹uË÷ÒýÎļþ´aeÔÚ¡£$addedÊÇÒ»¸oÈ«¾Ö±aÁ¿¡£
echo "Ë÷ÒýÎļþ".$in_file."ÒѾ­´aeÔÚ£¬ÐÂË÷ÒýÒѾ­¼ÓÈeµ½ÎļþµÄ×iºo¡£
";
// echo "Çe¿´".$in_file.'µÄ×iºo'.$total.'Ìo¡£
';
}

else{
//½«ÐÂË÷ÒýÎļþдÈe×ÜË÷ÒýÎļþ¡£
$total_index=$index_path."k_index.html";
$fp_i=fopen($total_index,'a+');
$file_link="$index_describe
\r\n";
fputs($fp_i, $file_link);
fclose($fp_i);
}//if($added)
echo"µaÕaÀi¿´Ð¼ÓÈeµÄÎļþË÷Òý
";

//}//If(strlen($index_file)==0){

if($data_exist>0)
echo "Öظ´µÄÎÄÕ¹²".$data_exist."ƪ¡£
";
if($data_insert>0)
echo "мÓÈeµÄÎÄÕ¹²".$data_insert."ƪ¡£


";
$total=$data_exist+$data_insert;
echo"ÉÏ´«Îļþ".$UploadFile_name."¹²ÓÐÎÄÕÂ".$total."ƪ¡£";
echo"
*µ»Ø ";
echo"";
break;
}
?>

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例