<?php
/**
 * 愤怒的小鸟站
*/

/********密码验证***********/
$password='92game.net_hao123';		 //这个密码是登陆验证用的.您需要在模块里设置和这里一样的密码....注意一定需要修改.
if($password!=$_GET['pw']) exit('pwerror');   //安全检测,密码不符则退出


/****以下代码非专业人员不建议修改***************/
define('EmpireCMSAdmin','1');
define('EmpireCMSAPage','login');

require("../class/connect.php");
require("../class/db_sql.php");
require("../class/functions.php");
require LoadLang("pub/fun.php");
require("../class/delpath.php");
require("../class/copypath.php");
require("../class/t_functions.php");
require("../data/dbcache/class.php");
require("../data/dbcache/MemberLevel.php");

$link=db_connect();
$empire=new mysqlquery();

//验证用户
$loginin=RepPostVar($_REQUEST['username']);
$lur=$empire->fetch1("select * from {$dbtbpre}enewsuser where `username`='$loginin'");
if(!$lur) exit('不存在的用户名'.$loginin);


$logininid=$lur['userid'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];

$incftp=0;
if($public_r['phpmode'])
{
	include("../class/ftp.php");
	$incftp=1;
}
require("../class/hinfofun.php");
//$navtheid=(int)$_POST['filepass'];

$content =   $_POST['content'];

$content    =   preg_replace('/\\\/','',$content);
//$content    =   file_get_contents("11.htm");

$contentArray   =   explode('<ul class="content-link">',$content);

$classid    =   getClassId($contentArray[0]);

/**
 * 循环读取数据
*/
if( $classid ){
    foreach( $contentArray AS $key=>$row ){
        if( $key == 0 ){ continue; }
        
        $newarray['classid']    =   $classid;
        $newarray['checked']    =   '1';
        
        $rowContentFlag =   explode('<div class="content-con ">',$row);
        
        //处理数据
        $contentFlag    =   $rowContentFlag[0];
        
        //处理类信息
        $classFlag      =   $rowContentFlag[1];
        
        $classidflag    =   getClassId($classFlag);
        
        if( $classid == '' ){
            $classid    =   $classidflag;
            continue;
        }
        
        $contentArrayFlag   =   explode("</li>",$contentFlag);
        if( $contentArrayFlag ){
            foreach( $contentArrayFlag AS $key1=>$row1 ){
				
                $newarray['titlepic']  =   '';
                preg_match('/<a href="(.*)" target="_blank"(.*)">(.*)<\/a>/',$row1,$contentArrayFlag1);
                //=====================================判断标题重复
                $newarray['title']=trim($contentArrayFlag1[3]);
                if( preg_match('/更多/',$newarray['title']) ){ continue; }
                if( preg_match('/<img /',$newarray['title']) ){
                    preg_match('/<img src="(.*)"(.*)>(.*)/',$newarray['title'],$newarrayflag);
                    $newarray['title']  =   trim($newarrayflag[3]);
                    $newarray['titlepic']  =   $newarrayflag[1];
                }
                $newarray['titleurl']=$contentArrayFlag1[1];
                if( $newarray['title'] ){
                    $tr=$empire->fetch1("select id from {$dbtbpre}ecms_news where `title`='{$newarray['title']}'");
                    if(!$tr)
                    {
                    	AddNews($newarray,$logininid,$loginin,0);
                    }
                }
            }
        }
        
        $classid    =   $classidflag;
    }
}



//提取classid
function getClassId($content){
    global $empire,$dbtbpre;
    preg_match('/<h2 class="content-title">(.*)<span/',$content,$classnameArray);
    
    $classname  =   preg_replace('/\//','',$classnameArray[1]);
    if( $classname == '' ){ return ''; }
    
    $classflag  =   $empire->fetch1("select classid from {$dbtbpre}enewsclass where `classname`='$classname' AND bclassid <> 0 ");
    
    $classid    =   $classflag['classid'];
    
    return $classid;
}
db_close();
$empire=null;
?>