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


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

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

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


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



switch($mudi){
	case 'infoSet':
		$menuFileID = 274;
		$MB->IsSecMenuRight('alertBack',$menuFileID,$dataType);
		InfoSet();
		break;

	default:
		die('err');
}

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





// 基本设置
function InfoSet(){
	global $DB,$mudi,$menuFileID,$menuTreeID,$dataType,$dataTypeCN;

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

	$runMode			= OT::PostInt('runMode');
	$runArea			= OT::PostArrStr('runArea',',');
	$isTimeRun			= OT::PostInt('isTimeRun');
	$timeRunMin			= OT::PostInt('timeRunMin');
//		if ($timeRunMin < 10){ $timeRunMin = 10; }
	$timeRunItem		= OT::PostArrStr('timeRunItem',',');
	$isDayRun			= OT::PostInt('isDayRun');
	$dayRunItem			= OT::PostArrStr('dayRunItem',',');
	$dayRunList			= OT::PostArrStr('dayRunList',',');
	$isHtmlHome			= OT::PostInt('isHtmlHome');
	$htmlHomeMin		= OT::PostInt('htmlHomeMin');
		if ($htmlHomeMin < 10){ $htmlHomeMin = 10; }
	$isHtmlList			= OT::PostInt('isHtmlList');
	$htmlListMin		= OT::PostInt('htmlListMin');
		if ($htmlListMin < 1){ $htmlListMin = 1; }
	$htmlListNum		= OT::PostInt('htmlListNum');
		if ($htmlListNum < 1){ $htmlListNum = 1; }
		elseif ($htmlListNum > 20){ $htmlListNum = 20; }
	$htmlListMaxNum		= OT::PostInt('htmlListMaxNum');
		if ($htmlListMaxNum < 1){ $htmlListMaxNum = 1; }
	$isHtmlShow			= OT::PostInt('isHtmlShow');
	$htmlShowMin		= OT::PostInt('htmlShowMin');
		if ($htmlShowMin < 1){ $htmlShowMin = 1; }
	$htmlShowNum		= OT::PostInt('htmlShowNum');
		if ($htmlShowNum < 1){ $htmlShowNum = 1; }
		elseif ($htmlShowNum > 20){ $htmlShowNum = 20; }
	$htmlShowMaxNum		= OT::PostInt('htmlShowMaxNum');
		if ($htmlShowMaxNum < 1){ $htmlShowMaxNum = 1; }
	$htmlShowStartTime	= OT::PostStr('htmlShowStartTime');
		if (! strtotime($htmlShowStartTime)){ $htmlShowStartTime = '2018-1-1 00:00:01'; }
	$isColl				= OT::PostInt('isColl');
	$collMin			= OT::PostInt('collMin');
		if ($collMin < 5){ $collMin = 5; }
	$collNum			= OT::PostInt('collNum');
		if ($collNum < 1){ $collNum = 1; }
		elseif ($collNum > 10){ $collNum = 10; }
	$collFailNum		= OT::PostInt('collFailNum');
		if ($collFailNum < 1){ $collFailNum = 1; }
	$isSoftBak			= OT::PostInt('isSoftBak');
	$softBakMin			= OT::PostInt('softBakMin');
	$softBakArea		= OT::PostStr('softBakArea');
	$isDbBak			= OT::PostInt('isDbBak');
	$dbBakMin			= OT::PostInt('dbBakMin');
	$dbBakMode			= OT::PostStr('dbBakMode');
	$isApiItem			= OT::PostInt('isApiItem');
	$apiItemMin			= OT::PostInt('apiItemMin');
		if ($apiItemMin < 5){ $apiItemMin = 5; }
	$apiItemNum			= OT::PostInt('apiItemNum');
		if ($apiItemNum < 1){ $apiItemNum = 1; }
		elseif ($apiItemNum > 10){ $apiItemNum = 10; }
	$apiItemFailNum		= OT::PostInt('apiItemFailNum');
		if ($apiItemFailNum < 1){ $apiItemFailNum = 1; }
	$bigItemDay			= OT::PostInt('bigItemDay');
	$prevNextDay		= OT::PostInt('prevNextDay');
	$markNewsDay		= OT::PostInt('markNewsDay');
	$htmlShowDay		= OT::PostInt('htmlShowDay');
	$prevNextSize		= OT::PostInt('prevNextSize');
		if ($prevNextSize == 0){ $prevNextSize = 500; }
		elseif ($prevNextSize < 10){ $prevNextSize = 10; }
	// $prevNextPage		= OT::PostInt('prevNextPage');
	$markNewsSize		= OT::PostInt('markNewsSize');
		if ($markNewsSize == 0){ $markNewsSize = 500; }
		elseif ($markNewsSize < 10){ $markNewsSize = 10; }
	// $markNewsPage		= OT::PostInt('markNewsPage');

	$dayDateJud			= OT::PostInt('dayDateJud');
	$timeRunTimeJud		= OT::PostInt('timeRunTimeJud');
	$dayRunTimeJud		= OT::PostInt('dayRunTimeJud');
	$bigItemTimeJud		= OT::PostInt('bigItemTimeJud');
	$prevNextTimeJud	= OT::PostInt('prevNextTimeJud');
	$markNewsTimeJud	= OT::PostInt('markNewsTimeJud');
	$softBakTimeJud		= OT::PostInt('softBakTimeJud');
	$dbBakTimeJud		= OT::PostInt('dbBakTimeJud');
	$htmlHomeTimeJud	= OT::PostInt('htmlHomeTimeJud');
	$htmlHomeWapTimeJud	= OT::PostInt('htmlHomeWapTimeJud');
	$htmlListTimeJud	= OT::PostInt('htmlListTimeJud');
	$htmlListWapTimeJud	= OT::PostInt('htmlListWapTimeJud');
	$htmlShowTimeJud	= OT::PostInt('htmlShowTimeJud');
	$htmlShowWapTimeJud	= OT::PostInt('htmlShowWapTimeJud');
	$collTimeJud		= OT::PostInt('collTimeJud');
	$apiItemTimeJud		= OT::PostInt('apiItemTimeJud');
	$prevNextPageJud	= OT::PostInt('prevNextPageJud');
	$markNewsPageJud	= OT::PostInt('markNewsPageJud');

	$sign				= OT::PostStr('sign');
	$authState			= OT::PostStr('authState');

	$record=array();
	$record['ARS_runMode']			= $runMode;
	$record['ARS_runArea']			= $runArea;
	$record['ARS_isTimeRun']		= $isTimeRun;
	$record['ARS_timeRunMin']		= $timeRunMin;
	$record['ARS_timeRunItem']		= $timeRunItem;
	$record['ARS_isDayRun']			= $isDayRun;
	$record['ARS_dayRunItem']		= $dayRunItem;
	$record['ARS_dayRunList']		= $dayRunList;
	$record['ARS_isSoftBak']		= $isSoftBak;
	$record['ARS_softBakMin']		= $softBakMin;
	$record['ARS_softBakArea']		= $softBakArea;
	$record['ARS_isDbBak']			= $isDbBak;
	$record['ARS_dbBakMin']			= $dbBakMin;
	$record['ARS_dbBakMode']		= $dbBakMode;
	$record['ARS_isHtmlHome']		= $isHtmlHome;
	$record['ARS_htmlHomeMin']		= $htmlHomeMin;
	$record['ARS_bigItemDay']		= $bigItemDay;
	$record['ARS_prevNextDay']		= $prevNextDay;
	$record['ARS_markNewsDay']		= $markNewsDay;
	$record['ARS_prevNextSize']		= $prevNextSize;
	$record['ARS_markNewsSize']		= $markNewsSize;
	if ( $dayDateJud == 1 ){		$record['ARS_dayDate']			= OT::PostStr('dayDate'); }
	if ( $timeRunTimeJud == 1 ){	$record['ARS_timeRunTime']		= OT::PostStr('timeRunTime'); }
	if ( $dayRunTimeJud == 1 ){		$record['ARS_dayRunTime']		= OT::PostStr('dayRunTime'); }
	if ( $bigItemTimeJud == 1 ){	$record['ARS_bigItemTime']		= OT::PostStr('bigItemTime'); }
	if ( $prevNextTimeJud == 1 ){	$record['ARS_prevNextTime']		= OT::PostStr('prevNextTime'); }
	if ( $markNewsTimeJud == 1 ){	$record['ARS_markNewsTime']		= OT::PostStr('markNewsTime'); }
	if ( $softBakTimeJud == 1 ){	$record['ARS_softBakTime']		= OT::PostStr('softBakTime'); }
	if ( $dbBakTimeJud == 1 ){		$record['ARS_dbBakTime']		= OT::PostStr('dbBakTime'); }
	if ( $htmlHomeTimeJud == 1 ){	$record['ARS_htmlHomeTime']		= OT::PostStr('htmlHomeTime'); }
	if ( $htmlHomeWapTimeJud == 1 ){ $record['ARS_htmlHomeWapTime']	= OT::PostStr('htmlHomeWapTime'); }
	if ( $htmlListTimeJud == 1 ){	$record['ARS_htmlListTime']		= OT::PostStr('htmlListTime'); }
	if ( $htmlListWapTimeJud == 1 ){ $record['ARS_htmlListWapTime']	= OT::PostStr('htmlListWapTime'); }
	if ( $htmlShowTimeJud == 1 ){	$record['ARS_htmlShowTime']		= OT::PostStr('htmlShowTime'); }
	if ( $htmlShowWapTimeJud == 1 ){ $record['ARS_htmlShowWapTime']	= OT::PostStr('htmlShowWapTime'); }
	if ( $collTimeJud == 1 ){		$record['ARS_collTime']			= OT::PostStr('collTime'); }
	if ( $apiItemTimeJud == 1 ){	$record['ARS_apiItemTime']		= OT::PostStr('apiItemTime'); }
	if ( $prevNextPageJud == 1 ){	$record['ARS_prevNextPage']		= OT::PostInt('prevNextPage'); }
	if ( $markNewsPageJud == 1 ){	$record['ARS_markNewsPage']		= OT::PostInt('markNewsPage'); }
	if ($authState != 'false'){
		if (AppAutoHtml::Jud()){
			$record['ARS_isHtmlList']		= $isHtmlList;
			$record['ARS_isHtmlShow']		= $isHtmlShow;
			$record['ARS_htmlListMin']		= $htmlListMin;
			$record['ARS_htmlListNum']		= $htmlListNum;
			$record['ARS_htmlListMaxNum']	= $htmlListMaxNum;
			$record['ARS_htmlShowMin']		= $htmlShowMin;
			$record['ARS_htmlShowNum']		= $htmlShowNum;
			$record['ARS_htmlShowMaxNum']	= $htmlShowMaxNum;
			$record['ARS_htmlShowStartTime']= $htmlShowStartTime;
			$record['ARS_htmlShowDay']		= $htmlShowDay;
		}else{
			$record['ARS_isHtmlList']		= 0;
			$record['ARS_isHtmlShow']		= 0;
		}
		if (AppAutoColl::Jud()){
			$record['ARS_isColl']			= $isColl;
			$record['ARS_collMin']			= $collMin;
			$record['ARS_collNum']			= $collNum;
			$record['ARS_collFailNum']		= $collFailNum;
		}else{
			$record['ARS_isColl']			= 0;
		}
		if (AppAutoApiItem::Jud()){
			$record['ARS_isApiItem']		= $isApiItem;
			$record['ARS_apiItemMin']		= $apiItemMin;
			$record['ARS_apiItemNum']		= $apiItemNum;
			$record['ARS_apiItemFailNum']	= $apiItemFailNum;
		}else{
			$record['ARS_isApiItem']		= 0;
		}
	}

	$cacheStr = '';
	$judRes = $DB->UpdateParam('autoRunSys',$record,'ARS_ID=1');
		if ($judRes){
			$alertRes = '成功';

			$Cache = new Cache();
			$result = $Cache->Php('autoRunSys');	// 更新缓存文件
				if ($result){
					$cacheStr .= '\n../cache/autoRunSys.php 生成成功！';
				}else{
					$cacheStr .= '\n../cache/autoRunSys.php 生成失败，请检查该目录或者文件是否有写入/修改权限！';
				}
			$isJsRes = $Cache->Js('autoRunSys');
				if ($isJsRes){
					$cacheStr .= '\n../cache/js/autoRunSys.js 生成成功！';
				}else{
					$cacheStr .= '\n../cache/js/autoRunSys.js 生成失败，请检查该目录或者文件是否有写入/修改权限！';
				}
			if (Cache::UpdateConfigJs()){
				$cacheStr .= '\n../cache/js/configJs.js 生成成功！';
			}else{
				$cacheStr .= '\n../cache/js/configJs.js 生成失败，请检查该目录或者文件是否有写入/修改权限！';
			}
		}else{
			$alertRes = '失败';
		}

	Adm::AddLog(array(
		'note'		=> '【自动操作设置】保存'. $alertRes .'！',
		));

	JS::AlertHrefEnd('保存'. $alertRes .'.'. $cacheStr, $backURL);

}

?>