<?php
require(dirname(__FILE__) .'/check.php');
$skin->CheckIframe();


/* **** 版权所有 ****

 程序开发：网钛科技
 网钛CMS官网：http://otcms.com
 网钛IDC官网：http://idccms.com
 ＱＱ：877873666
 微信：QQ877873666
 邮箱：877873666@qq.com

 **** 版权所有 **** */


//用户检测
$MB->Open('','login');



switch ($mudi){
	case 'add':
		$menuFileID = 93;
		$MB->IsSecMenuRight('alertBack',$menuFileID,$dataType);
		AddOrRev();
		break;

	case 'rev':
		$menuFileID = 94;
		$MB->IsSecMenuRight('alertBack',$menuFileID,$dataType);
		AddOrRev();
		break;

	case 'del':
		$menuFileID = 95;
		$MB->IsSecMenuRight('alert',$menuFileID,$dataType);
		del();
		break;

	case 'moreSet':
		$menuFileID = 94;
		$MB->IsSecMenuRight('alertBack',$menuFileID,$dataType);
		MoreSetDeal();
		break;

	case 'moreAddi':
		$menuFileID = 94;
		$MB->IsSecMenuRight('alertBack',$menuFileID,$dataType);
		MoreAddiDeal();
		break;

	case 'moreUpdateHtmlDir':
		$menuFileID = 94;
		$MB->IsSecMenuRight('alert',$menuFileID,$dataType);
		MoreUpdateHtmlDir();
		break;

	case 'moreUpdateTimeDir':
		$menuFileID = 94;
		$MB->IsSecMenuRight('alert',$menuFileID,$dataType);
		MoreUpdateTimeDir();
		break;

	case 'moreCountInfo':
		$menuFileID = 94;
		$MB->IsSecMenuRight('alert',$menuFileID,$dataType);
		MoreCountInfo();
		break;

	default:
		die('err');
}

$MB->Close();
$DB->Close();





// 添加与修改
function AddOrRev(){
	global $DB,$MB,$mudi,$menuFileID,$menuTreeID;

	$backURL		= OT::PostStr('backURL');
	$dataType		= OT::PostStr('dataType');
	$dataTypeCN		= OT::PostStr('dataTypeCN');
	$dataID			= OT::PostInt('dataID');

	$htmlNameOld	= OT::PostStr('htmlNameOld');
	$oldFatID		= OT::PostInt('oldFatID');

	$theme			= OT::PostReplaceStr('theme','html');
	$themeB			= OT::PostInt('themeB');
	$themeColor		= OT::PostStr('themeColor');
	$themeStyle		= '';
		if ($themeB == 1){ $themeStyle .= 'font-weight:bold;'; }
		if ($themeColor != ''){ $themeStyle .= 'color:'. $themeColor .';'; }
	$fatID			= OT::PostInt('fatID');
		if ($fatID > 0){ $level = 2; }else{ $level = 1; }
	$mode			= OT::PostStr('mode');
	$webURL			= OT::PostStr('webURL');
	$isEncUrl		= OT::PostInt('isEncUrl');
		if ($webURL == 'http://'){ $webURL=''; }
	$webID			= OT::PostInt('webID');
	$isTitle		= OT::PostInt('isTitle');
	$titleAddi		= OT::PostRStr('titleAddi');
	$template		= OT::PostStr('template');
	$templateWap	= OT::PostStr('templateWap');
	$webKey			= OT::PostStr('webKey');
	$webDesc		= Str::RegExp(OT::PostStr('webDesc'),'html');
	$openMode		= OT::PostStr('openMode');
	$showMode		= OT::PostInt('showMode');
	$showNum		= OT::PostInt('showNum');
		if ($showNum <= 0){ $showNum = 10; }
	$wapShowMode	= OT::PostInt('wapShowMode');
	$wapShowNum		= OT::PostInt('wapShowNum');
		if ($wapShowNum <= 0){ $wapShowNum = 10; }
	$listInfo		= OT::Post('listInfo');
		if (is_array($listInfo)){ $listInfo = implode(',',$listInfo); }
	$subNewNum		= OT::PostInt('subNewNum');
	$subRecomNum	= OT::PostInt('subRecomNum');
	$subHotNum		= OT::PostInt('subHotNum');
	$isRightMenu	= OT::PostInt('isRightMenu');
	$isMenu			= OT::PostInt('isMenu');
	$isSubMenu		= OT::PostInt('isSubMenu');
	$isHome			= OT::PostInt('isHome');
	$isHomeImg		= OT::PostInt('isHomeImg');
	$homeIco		= OT::PostInt('homeIco');
	$homeNum		= OT::PostInt('homeNum');
		if ($homeNum+$isHomeImg == 0){ $homeNum = 10; }
	$isWap			= OT::PostInt('isWap');
	$isWapHome		= OT::PostInt('isWapHome');
	$isWapHomeDate	= OT::PostInt('isWapHomeDate');
	$wapHomeIco		= OT::PostInt('wapHomeIco');
	$wapHomeImgNum	= OT::PostInt('wapHomeImgNum');
	$wapHomeNum		= OT::PostInt('wapHomeNum');
		if ($wapHomeNum+$wapHomeImgNum == 0){ $wapHomeNum = 6; }
	$isItemDate		= OT::PostInt('isItemDate');
	$isItemType		= OT::PostInt('isItemType');
	$isUser			= OT::PostInt('isUser');
	$isAdminUser	= OT::PostInt('isAdminUser');
	$rank			= OT::PostInt('rank');
	$itemRank		= OT::PostInt('itemRank');
	$wapItemRank	= OT::PostInt('wapItemRank');
	$isWapSubMenu	= OT::PostInt('isWapSubMenu');
	$htmlName		= OT::PostStr('htmlName');
	$isChangeHtmlName = OT::PostInt('isChangeHtmlName');
	$lookScore		= OT::PostInt('lookScore');
	$state			= OT::PostInt('state');
	$wapHomeMode	= OT::PostInt('wapHomeMode');
	$isWapHomeType	= OT::PostInt('isWapHomeType');

	$listMaxPage	= OT::PostInt('listMaxPage');
	$hiddenContent1	= OT::PostStr('hiddenContent1');
	$hiddenContent2	= OT::PostStr('hiddenContent2');
	$score1			= OT::PostInt('score1');
	$score2			= OT::PostInt('score2');
	$score3			= OT::PostInt('score3');
	$cutScore1		= OT::PostInt('cutScore1');
	$cutScore2		= OT::PostInt('cutScore2');
	$cutScore3		= OT::PostInt('cutScore3');
	$userGroupList	= OT::PostArrStr('userGroupList', ',');
	$freeGroupList	= OT::PostArrStr('freeGroupList', ',');
	$cutQuickMoney	= OT::PostFloat('cutQuickMoney');
	$pwdAnswer		= OT::PostStr('pwdAnswer');
	$pwdImg			= OT::PostStr('pwdImg');
	$pwdNote		= OT::PostStr('pwdNote');
	$topAddiID		= OT::PostInt('topAddiID');
	$addiID			= OT::PostInt('addiID');
	$placeMode		= OT::PostInt('placeMode');
	$infoTypeMode	= OT::PostStr('infoTypeMode');
		if (strlen($infoTypeMode) == 0){ $infoTypeMode = 'def'; }
	$addition		= OT::PostArrStr('addition', ',');
	$event			= OT::PostArrStr('event', ',');
		if ($mode != 'item'){
			$isHome = 0;
			$isUser = 0;
			$isAdminUser = 0;
		}
//		If fatID>0 And showMode=5 Then showMode=1
		switch ($mode){
			case 'topic':			$webID	= OT::PostInt('topicID');		break;
			case 'taobaoke':		$webID	= OT::PostInt('taobaokeID');	break;
			case 'idcPro':			$webID	= OT::PostInt('idcProID');		break;
			case 'urlHome':			$webURL	= '{%网站根路径%}';				break;
			case 'urlMessage':		$webURL	= '{%网站根路径%}message.php';	break;
			case 'urlBbs':			$webURL	= '{%网站根路径%}message/';		break;
			case 'urlGift':			$webURL	= '{%网站根路径%}w.php?m=gift';		break;
			case 'urlUserWork':		$webURL	= '{%网站根路径%}plugin_deal.php?m=userGroupWork&mode=alertClose'; $openMode = '_blank';	break;
			case 'urlQiandao':		$webURL	= '{%网站根路径%}plugin_deal.php?m=qiandao&mode=alertClose'; $openMode = '_blank';		break;
			case 'urlTag':			$webURL	= '{%网站根路径%}w.php?m=tags';		break;
		}
	
	if ($theme==''){
		JS::AlertBackEnd('表单内容接收不全');
	}

	$record=array();
	$record['IT_revTime']		= TimeDate::Get();
	$record['IT_level']			= $level;
	$record['IT_fatID']			= $fatID;
	$record['IT_theme']			= $theme;
	$record['IT_mode']			= $mode;
	$record['IT_URL']			= $webURL;
	$record['IT_isEncUrl']		= $isEncUrl;
	$record['IT_webID']			= $webID;
	$record['IT_webKey']		= $webKey;
	$record['IT_webDesc']		= $webDesc;
	$record['IT_openMode']		= $openMode;
	$record['IT_showMode']		= $showMode;
	$record['IT_showNum']		= $showNum;
	$record['IT_wapShowMode']	= $wapShowMode;
	$record['IT_wapShowNum']	= $wapShowNum;
	$record['IT_isMenu']		= $isMenu;
	$record['IT_isSubMenu']		= $isSubMenu;
	$record['IT_listInfo']		= $listInfo;
	$record['IT_subNewNum']		= $subNewNum;
	$record['IT_subRecomNum']	= $subRecomNum;
	$record['IT_subHotNum']		= $subHotNum;
	$record['IT_isWap']			= $isWap;
	$record['IT_isHome']		= $isHome;
	$record['IT_isHomeImg']		= $isHomeImg;
	$record['IT_homeIco']		= $homeIco;
	$record['IT_homeNum']		= $homeNum;
	$record['IT_isWapHome']		= $isWapHome;
	$record['IT_isWapHomeDate']	= $isWapHomeDate;
//	$record['IT_wapHomeIco']	= $wapHomeIco;
	$record['IT_wapHomeImgNum']	= $wapHomeImgNum;
	$record['IT_wapHomeNum']	= $wapHomeNum;
	$record['IT_isItemDate']	= $isItemDate;
	$record['IT_isItemType']	= $isItemType;
	$record['IT_isUser']		= $isUser;
	$record['IT_isAdminUser']	= $isAdminUser;
	$record['IT_rank']			= $rank;
	$record['IT_itemRank']		= $itemRank;
	$record['IT_wapItemRank']	= $wapItemRank;
	$record['IT_isWapSubMenu']	= $isWapSubMenu;
	$record['IT_htmlName']		= $htmlName;
	$record['IT_state']			= $state;
	$record['IT_wapHomeMode']	= $wapHomeMode;
	$record['IT_isWapHomeType']	= $isWapHomeType;
	$record['IT_listMaxPage']	= $listMaxPage;

	$record['IT_hiddenContent1']	= $hiddenContent1;
	$record['IT_hiddenContent2']	= $hiddenContent2;
	$record['IT_score1']			= $score1;
	$record['IT_score2']			= $score2;
	$record['IT_score3']			= $score3;
	$record['IT_cutScore1']			= $cutScore1;
	$record['IT_cutScore2']			= $cutScore2;
	$record['IT_cutScore3']			= $cutScore3;
	$record['IT_userGroupList']		= $userGroupList;
	$record['IT_freeGroupList']		= $freeGroupList;
	$record['IT_cutQuickMoney']		= $cutQuickMoney;
	$record['IT_pwdAnswer']			= $pwdAnswer;
	$record['IT_pwdImg']			= $pwdImg;
	$record['IT_pwdNote']			= $pwdNote;
	$record['IT_topAddiID']			= $topAddiID;
	$record['IT_addiID']			= $addiID;

	$record['IT_placeMode']		= $placeMode;
	$record['IT_infoTypeMode']	= $infoTypeMode;
	$record['IT_addition']		= $addition;
	$record['IT_event']			= $event;

	if (AppBase::Jud()){
		$record['IT_themeStyle']	= $themeStyle;
		$record['IT_isTitle']		= $isTitle;
		$record['IT_titleAddi']		= $titleAddi;
		$record['IT_template']		= $template;
		$record['IT_isRightMenu']	= $isRightMenu;
		$record['IT_lookScore']		= $lookScore;
	}
	if (AppWap::Jud()){
		$record['IT_templateWap']	= $templateWap;
	}

	$dealrec=$DB->query('select * from '. OT_dbPref .'infoType where IT_ID='. $dataID);
		if (! $row = $dealrec->fetch()){
			$alertMode = '添加';
			$record['IT_time']	= TimeDate::Get();

			$judRes = $DB->InsertParam('infoType',$record);
		}else{
			$alertMode = '修改';
			if ($oldFatID==0 && $fatID>0){
				$checkexe=$DB->query('select IT_ID from '. OT_dbPref .'infoType where IT_fatID='. $dataID);
				if ($checkexe->fetch()){
					JS::AlertBackEnd('该栏目下存在子栏目，请选转移或删除子栏目，再选择非顶级分类。');
				}
				unset($checkexe);
			}
			if ($oldFatID != $fatID){
				if ($oldFatID == 0){ $oldLevel=1; }else{ $oldLevel=2; }
				if ($fatID == 0){
					$setStr="IF_typeStr=',". $dataID .",',IF_type1ID=". $dataID .",IF_type2ID=0";
				}else{
					$setStr="IF_typeStr=',". $fatID .",". $dataID .",',IF_type1ID=". $fatID .",IF_type2ID=". $dataID ."";
				}
				$DB->query('update '. OT_dbPref .'info set '. $setStr .' where IF_type'. $oldLevel .'ID='. $dataID);
			}
			$judRes = $DB->UpdateParam('infoType',$record,'IT_ID='. $dataID);
		}
	unset($dealrec);

	if ($alertMode == '添加'){
		if ($dataID == 0){ $dataID=$DB->GetOne('select max(IT_ID) from '. OT_dbPref .'infoType'); }
		$backURL = 'infoType.php?mudi=add&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&dataID='. $dataID .'';
	}

	if ($alertMode == '修改' && $htmlNameOld != $htmlName && $htmlName != ''){
		if ($DB->GetOne('select count(IT_ID) from '. OT_dbPref .'infoType where IT_fatID='. $dataID) == 0){
			$DB->query("update ". OT_dbPref ."info set IF_infoTypeDir=". $DB->ForStr($htmlName .'/') ." where IF_typeStr like '%,". $dataID .",%'");
		}
	}

	if ($judRes == true){
		$alertRes = '成功';
	}else{
		$alertRes = '失败';
	}

	Adm::AddLog(array(
		'theme'	=> $theme,
		'note'	=> '【'. $dataTypeCN .'】'. $alertMode . $alertRes .'！',
		));

	JS::AlertHrefEnd($alertMode . $alertRes .'！', $backURL);
}



// 删除
function del(){
	global $DB,$skin,$mudi,$menuFileID,$menuTreeID,$systemArr;

	$dataType	= OT::GetStr('dataType');
	$dataTypeCN	= OT::GetStr('dataTypeCN');
	$dataID		= OT::GetInt2( OT::ParaArr('id') );
	$theme		= OT::GetStr('theme');

	if ($dataID<=0){
		JS::AlertEnd('指定ID错误！');
	}

	$IT_htmlName = '';
	$checkexe = $DB->query('select IT_ID,IT_level,IT_fatID,IT_htmlName from '. OT_dbPref .'infoType where IT_ID='. $dataID);
	if (! $row = $checkexe->fetch()){
		JS::AlertEnd('该栏目不存在');
	}else{
		if ($row['IT_level'] == 1 || $row['IT_fatID'] == 0){
			$checkexe2 = $DB->query('select IT_ID from '. OT_dbPref .'infoType where IT_fatID='. $dataID);
			if ($checkexe2->fetch()){
				JS::AlertEnd('该栏目下存在子栏目，请先删除子栏目。');
			}
			unset($checkexe2);
		}
		$IT_htmlName = $row['IT_htmlName'];
	}
	unset($checkexe);

	$checkexe = $DB->query("select IF_ID from ". OT_dbPref ."info where IF_typeStr like '%,". $dataID .",%'");
	if ($checkexe->fetch()){
		JS::AlertEnd('有文章占用该栏目，请先转移或删除被占用的文章。');
	}
	unset($checkexe);

	$judRes = $DB->query('delete from '. OT_dbPref .'infoType where IT_ID='. $dataID);
	if ($judRes){
		$alertRes = '成功';
		if ($systemArr['SYS_newsShowUrlMode'] == 'html-2.x'){
			File::Del(OT_ROOT . Url::ListID('',$IT_htmlName,$dataID,0));
			File::Del(OT_ROOT .'wap/'. Url::ListID('',$IT_htmlName,$dataID,0));
			$isDel = true;
			$delNum = 1;
			while ($isDel){
				$delNum ++;
				if (file_exists(OT_ROOT . Url::ListID('',$IT_htmlName,$dataID,$delNum))){
					File::Del(OT_ROOT . Url::ListID('',$IT_htmlName,$dataID,$delNum));
					File::Del(OT_ROOT .'wap/'. Url::ListID('',$IT_htmlName,$dataID,$delNum));
				}else{
					$isDel = false;
				}
			}
		}
	}else{
		$alertRes = '失败';
	}

	Adm::AddLog(array(
		'theme'	=> $theme,
		'note'	=> '【'. $dataTypeCN .'】删除'. $alertRes .'！',
		));
	
	JS::ParentHiddenEnd('data'. $dataID);
}



// 选项批量设置
function MoreSetDeal(){
	global $DB,$mudi,$menuFileID,$menuTreeID,$dataType,$dataTypeCN,$systemArr;

	$backURL		= OT::PostStr('backURL');
	$dataType		= OT::PostStr('dataType');
	$dataTypeCN		= OT::PostStr('dataTypeCN');
	$moreSetTo		= OT::PostRegExpStr('moreSetTo','sql');
	$moreSetToCN	= OT::PostRegExpStr('moreSetToCN','sql');
	$selDataID		= OT::Post('selDataID');

	$selCount = OT::NewCount($selDataID);
	if ($selCount <= 0){
		JS::AlertBackEnd('请先选择要设置的记录.');
	}
	if ($moreSetTo==''){
		JS::AlertBackEnd('请选择批量设置的操作.');
	}

	$whereStr = '';
	for ($i=0; $i<$selCount; $i++){
		$whereStr .= ','. intval($selDataID[$i]);
	}
	if ($whereStr == ''){
		JS::AlertBackEnd('请先选择要设置的记录.');
	}

	$addiJud = false;
	$addiMode = -1;
	$addiStr = '';
	switch ($moreSetTo){
		case 'isUser1':			$dealStr = 'IT_isUser=1';		break;
		case 'isUser0':			$dealStr = 'IT_isUser=0';		break;
		case 'isAdminUser1':	$dealStr = 'IT_isAdminUser=1';	break;
		case 'isAdminUser0':	$dealStr = 'IT_isAdminUser=0';	break;
		case 'isMenu1':			$dealStr = 'IT_isMenu=1';		break;
		case 'isMenu0':			$dealStr = 'IT_isMenu=0';		break;
		case 'isSubMenu1':		$dealStr = 'IT_isSubMenu=1';	break;
		case 'isSubMenu0':		$dealStr = 'IT_isSubMenu=0';	break;
		case 'isWap1':			$dealStr = 'IT_isWap=1';		break;
		case 'isWap0':			$dealStr = 'IT_isWap=0';		break;
		case 'isHome1':			$dealStr = 'IT_isHome=1';		break;
		case 'isHome0':			$dealStr = 'IT_isHome=0';		break;
		case 'isItemDate1':		$dealStr = 'IT_isItemDate=1';	break;
		case 'isItemDate0':		$dealStr = 'IT_isItemDate=0';	break;
		case 'isItemType1':		$dealStr = 'IT_isItemType=1';	break;
		case 'isItemType0':		$dealStr = 'IT_isItemType=0';	break;
		case 'isRightMenu0':	$dealStr = 'IT_isRightMenu=0';	break;
		case 'isRightMenu2':	$dealStr = 'IT_isRightMenu=2';	break;
		case 'isRightMenu1':	$dealStr = 'IT_isRightMenu=1';	break;
		case 'isRightMenu99':	$dealStr = 'IT_isRightMenu=99';	break;
		case 'showMode1':		$dealStr = 'IT_showMode=1';		break;
		case 'showMode2':		$dealStr = 'IT_showMode=2';		break;
		case 'showMode3':		$dealStr = 'IT_showMode=3';		break;
		case 'showMode4':		$dealStr = 'IT_showMode=4';		break;
		case 'showMode5':		$dealStr = 'IT_showMode=5';		break;
		case 'showMode6':		$dealStr = 'IT_showMode=6';		break;
		case 'showMode7':		$dealStr = 'IT_showMode=7';		break;
		case 'isWapHome1':		$dealStr = 'IT_isWapHome=1';	break;
		case 'isWapHome0':		$dealStr = 'IT_isWapHome=0';	break;
		case 'isWapHomeDate1':	$dealStr = 'IT_isWapHomeDate=1';break;
		case 'isWapHomeDate0':	$dealStr = 'IT_isWapHomeDate=0';break;
		case 'isWapHomeType1':	$dealStr = 'IT_isWapHomeType=1';break;
		case 'isWapHomeType0':	$dealStr = 'IT_isWapHomeType=0';break;
		case 'wapHomeMode1':	$dealStr = 'IT_wapHomeMode=1';	break;
		case 'wapHomeMode2':	$dealStr = 'IT_wapHomeMode=2';	break;
		case 'wapHomeMode3':	$dealStr = 'IT_wapHomeMode=3';	break;
		case 'wapHomeMode4':	$dealStr = 'IT_wapHomeMode=4';	break;
		case 'wapHomeMode7':	$dealStr = 'IT_wapHomeMode=7';	break;
		case 'isWapSubMenu0':	$dealStr = 'IT_isWapSubMenu=0';	break;
		case 'isWapSubMenu1':	$dealStr = 'IT_isWapSubMenu=1';	break;
		case 'isWapSubMenu2':	$dealStr = 'IT_isWapSubMenu=2';	break;
		case 'isWapSubMenu3':	$dealStr = 'IT_isWapSubMenu=3';	break;
		case 'isWapSubMenu4':	$dealStr = 'IT_isWapSubMenu=4';	break;
		case 'isWapSubMenu99':	$dealStr = 'IT_isWapSubMenu=99';break;
		case 'wapShowMode1':	$dealStr = 'IT_wapShowMode=1';	break;
		case 'wapShowMode2':	$dealStr = 'IT_wapShowMode=2';	break;
		case 'wapShowMode3':	$dealStr = 'IT_wapShowMode=3';	break;
		case 'wapShowMode4':	$dealStr = 'IT_wapShowMode=4';	break;
		case 'wapShowMode7':	$dealStr = 'IT_wapShowMode=7';	break;
		case 'placeMode0':		$dealStr = 'IT_placeMode=0';	break;
		case 'placeMode1':		$dealStr = 'IT_placeMode=1';	break;
		case 'placeMode2':		$dealStr = 'IT_placeMode=2';	break;
		case 'placeMode50':		$dealStr = 'IT_placeMode=50';	break;
		case 'placeMode51':		$dealStr = 'IT_placeMode=51';	break;
		case 'infoTypeMode_def':		$dealStr = 'IT_infoTypeMode="def"';			break;
		case 'infoTypeMode_title':		$dealStr = 'IT_infoTypeMode="title"';		break;
		case 'infoTypeMode_imgTitle':	$dealStr = 'IT_infoTypeMode="imgTitle"';	break;
		case 'state1':			$dealStr = 'IT_state=1';		break;
		case 'state0':			$dealStr = 'IT_state=0';		break;
		default :
			JS::AlertBackEnd('目的不明确.');
			break;
	}

	$judRes = $DB->query('update '. OT_dbPref .'infoType set '. $dealStr .' where IT_ID in (0'. $whereStr .')');
		if ($judRes){
			$alertRes = '成功';
		}else{
			$alertRes = '失败';
		}

	Adm::AddLog(array(
		'note'		=> '【'. $dataTypeCN .'】批量设置成【'. $moreSetToCN .'】'. $alertRes .'！',
		));

	JS::AlertHref('批量设置成【'. $moreSetToCN .'】'. $alertRes .'.',$backURL);
}



// 文本框批量设置
function MoreAddiDeal(){
	global $DB,$mudi,$menuFileID,$menuTreeID,$dataType,$dataTypeCN,$systemArr;

	$backURL		= OT::PostStr('backURL');
	$dataType		= OT::PostStr('dataType');
	$dataTypeCN		= OT::PostStr('dataTypeCN');
	$moreTxtSel		= OT::PostRegExpStr('moreTxtSel','sql');
	$selDataID		= OT::Post('selDataID');

	$selCount = OT::NewCount($selDataID);
	if ($selCount <= 0){
		JS::AlertBackEnd('请先选择要设置的记录.');
	}

	$whereStr = '';
	for ($i=0; $i<$selCount; $i++){
		$whereStr .= ','. intval($selDataID[$i]);
	}
	if ($whereStr == ''){
		JS::AlertBackEnd('请先选择要设置的记录.');
	}

	$record = array();
	if (in_array($moreTxtSel,array('listMaxPage', 'isHomeImg','homeNum','showNum','subNewNum','subRecomNum','subHotNum','wapHomeImgNum','wapHomeNum','wapShowNum'))){
		$moreTxtVal = OT::PostInt('moreTxtVal');
		$record['IT_'. $moreTxtSel] = $moreTxtVal;

		switch ($moreTxtSel){
			case 'listMaxPage':		$selName = '静态列表页最大页码';		break;
			case 'isHomeImg':		$selName = 'PC首页栏目图文数量';	break;
			case 'homeNum':			$selName = 'PC首页栏目文章数量';	break;
			case 'showNum':			$selName = 'PC列表页每页数量';		break;
			case 'subNewNum':		$selName = 'PC列表页右侧最新文章数';	break;
			case 'subRecomNum':		$selName = 'PC列表页右侧推荐文章数';	break;
			case 'subHotNum':		$selName = 'PC列表页右侧热门文章数';	break;
			case 'wapHomeImgNum':	$selName = 'WAP首页栏目图文数量';	break;
			case 'wapHomeNum':		$selName = 'WAP首页栏目文章数量';	break;
			case 'wapShowNum':		$selName = 'WAP列表页每页数量';		break;
		}
		$alertStr = $selName .' 批量设置为['. $moreTxtVal .']';

	}else{
		JS::AlertBackEnd('请选择批量设置的字段['. $moreTxtSel .'].');
	}

	$judRes = $DB->UpdateParam('infoType', $record, 'IT_ID in (0'. $whereStr .')');
		if ($judRes){
			$alertRes = '成功';
		}else{
			$alertRes = '失败';
		}

	Adm::AddLog(array(
		'note'		=> '【'. $dataTypeCN .'】'. $alertStr . $alertRes .'！',
		));

	JS::AlertHref($alertStr . $alertRes .'！', $backURL);
}



// 批量更新栏目文章的静态目录名
function MoreUpdateHtmlDir(){
	global $DB;

	$backURL		= OT::PostStr('backURL');
	$dataType		= OT::PostStr('dataType');
	$dataTypeCN		= OT::PostStr('dataTypeCN');
	$selDataID		= OT::Post('selDataID');

	$selCount = OT::NewCount($selDataID);
	if ($selCount <= 0){
		JS::AlertBackEnd('请先选择要更新的记录.');
	}

	echo('<script language="javascript" type="text/javascript">');
	
	for ($i=0; $i<$selCount; $i++){
		$selID = intval($selDataID[$i]);
		if ($selID == -1){
			$newHtmlName = 'announ';
			$DB->query('update '. OT_dbPref .'info set IF_infoTypeDir='. $DB->ForStr($newHtmlName .'/') ." where IF_typeStr='announ'");
			echo('
			try { parent.$id("infoType_1").innerHTML=\'<span style="color:green;">[静态目录更新]</span>\'; }catch (e){}
			');
		}elseif ($selID > 0){
			$newHtmlName = $DB->GetOne('select IT_htmlName from '. OT_dbPref .'infoType where IT_ID='. $selID);
			if (strlen($newHtmlName) > 0){
				$DB->query('update '. OT_dbPref .'info set IF_infoTypeDir='. $DB->ForStr($newHtmlName .'/') ." where IF_typeStr like '%,". $selID .",%'");
				echo('
				try { parent.$id("infoType'. $selID .'").innerHTML=\'<span style="color:green;">[静态目录更新]</span>\'; }catch (e){}
				');
			}else{
				echo('
				try { parent.$id("infoType'. $selID .'").innerHTML=\'<span style="color:red;">[静态目录为空]</span>\'; }catch (e){}
				');
			}
		}
	}
	
	echo('</script>');
}



// 批量更新栏目文章的时间目录名
function MoreUpdateTimeDir(){
	global $DB;

	$backURL		= OT::PostStr('backURL');
	$dataType		= OT::PostStr('dataType');
	$dataTypeCN		= OT::PostStr('dataTypeCN');
	$selDataID		= OT::Post('selDataID');

	$selCount = OT::NewCount($selDataID);
	if ($selCount <= 0){
		JS::AlertBackEnd('请先选择要更新的记录.');
	}

	$htmlDatetimeDir = $DB->GetOne('select SYS_htmlDatetimeDir from '. OT_dbPref .'system');

	@ini_set('max_execution_time', 0);
	@set_time_limit(0); 
	@ob_end_clean();
	ob_implicit_flush(1);

	ob_start();
	for ($i=0; $i<$selCount; $i++){
		$selID = intval($selDataID[$i]);
		if ($selID == -1){
			$infoexe = $DB->query('select IF_ID,IF_time,IF_datetimeDir from '. OT_dbPref ."info where IF_typeStr='announ'");
			while ($row = $infoexe->fetch()){
				$DB->UpdateParam('info', array('IF_datetimeDir'=>Info::DatetimeDirName($row['IF_time'],$htmlDatetimeDir) .'/'), 'IF_ID='. $row['IF_ID']);
			}
			$infoexe = null;
			
			echo('
			<script language="javascript" type="text/javascript">
			try { parent.$id("infoType_1").innerHTML=\'<span style="color:green;">[时间目录更新]</span>\'; }catch (e){}
			</script>
			');
		}elseif ($selID > 0){
			$infoexe = $DB->query('select IF_ID,IF_time,IF_datetimeDir from '. OT_dbPref ."info where IF_typeStr like '%,". $selID .",%'");
			while ($row = $infoexe->fetch()){
				$DB->UpdateParam('info', array('IF_datetimeDir'=>Info::DatetimeDirName($row['IF_time'],$htmlDatetimeDir) .'/'), 'IF_ID='. $row['IF_ID']);
			}
			$infoexe = null;

			echo('
			<script language="javascript" type="text/javascript">
			try { parent.$id("infoType'. $selID .'").innerHTML=\'<span style="color:green;">[时间目录更新]</span>\'; }catch (e){}
			</script>
			');
		}
		ob_flush();
		flush();
	}

}



// 批量统计文章
function MoreCountInfo(){
	global $DB;

	$backURL		= OT::PostStr('backURL');
	$dataType		= OT::PostStr('dataType');
	$dataTypeCN		= OT::PostStr('dataTypeCN');
	$selDataID		= OT::Post('selDataID');

	$selCount = OT::NewCount($selDataID);
	if ($selCount <= 0){
		JS::AlertBackEnd('请先选择要统计的记录.');
	}

	echo('<script language="javascript" type="text/javascript">');
	
	for ($i=0; $i<$selCount; $i++){
		$selID = intval($selDataID[$i]);
		if ($selID == -1){
			echo('
			try { parent.$id("infoType_1").innerHTML="('. $DB->GetOne('select count(IF_ID) from '. OT_dbPref .'info where IF_type1ID=-1') .')"; }catch (e){}
			');
		}elseif ($selID > 0){
			echo('
			try { parent.$id("infoType'. $selID .'").innerHTML="('. $DB->GetOne("select count(IF_ID) from ". OT_dbPref ."info where IF_typeStr like '%,". $selID .",%'") .')"; }catch (e){}
			');
		}
	}
	
	echo('</script>');
}
?>