<?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");

/*
$_POST[title]='tt';
$_POST[cjid]='11';
$_POST[cjsource]='tt';
$_POST[playurl]='playurl';
$_POST[volumeid]='22';
$_POST[volumename]='volumename';
$_POST[enews]='AddNews';
$_POST[username]='admin';
$_POST[classid]='7';
*/
if(empty($_POST))
{
	//这里刷新列表
	echo "<select name='list'>";
	echo maketree($cates,0,'');
	echo '</select>';
	exit();
}
$link=db_connect();
$empire=new mysqlquery();

//验证用户
$loginin=RepPostVar($_POST['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");

//=====================================判断标题重复

$fileflag   =   $_POST['content'];

$array  =   explode('</li>',$fileflag);

foreach( $array AS $key=>$row ){
    if( $key > 29 ){ break; }
    $row    =   preg_replace("/\\\/",'',$row);
    preg_match('/(.*)href="(.*)" class="ws-img" title="(.*)"><img width="150" height="90"  src="(.*)" \/><\/a><a(.*)/',$row,$arrayflag);
    $newarray[$key]['titleurl']    =   $arrayflag[2];	
    $newarray[$key]['title']   =   $arrayflag[3];	
    $newarray[$key]['titlepic']     =   $arrayflag[4];
}
$success    =   0;
foreach( $newarray AS $key=>$row ){
    $row[classid]   =   $_POST['classid'];
    $row[checked]   =   1;
    $tr=$empire->fetch1("select id from {$dbtbpre}ecms_news where `title`='$row[title]' AND classid = '21' ");
    if(!$tr['id'])
    {
    	AddNews($row,$logininid,$loginin,0);
        $success++;
    }
}

echo $error?$error.'成功:'.$success.'个':'全部成功';


db_close();
$empire=null;

/***生成目录的一个遍历算法***/
function maketree($ar,$id,$pre)
{
	$ids='';
	foreach($ar as $k=>$v){
		$pid=$v['pid'];
		$cname=$v['cname'];
		$cid=$v['cid'];
		if($pid==$id)
		{
			$ids.="<option value='$cid'>{$pre}{$cname}</option>";
			foreach($ar as $kk=>$vv)
			{
				$pp=$vv['pid'];
				if($pp==$cid)
				{ 
					$ids.=maketree($ar,$cid,$pre);
					break;
				}
			}
		}
	}
	return $ids;
}
?>