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


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

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

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


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

if ($dataType==''){$dataType=OT::PostRegExpStr('dataType','sql');}

$MB->IsSecMenuRight('alertBack',122,$dataType);

switch($mudi){
	case 'deal':
		Deal();
		break;

	case 'saveDef':
		SaveDef();
		break;

	case 'menuUrlSimp':
		MenuUrlSimp();
		break;

	default:
		die('err');
}

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





// 修改后台参数设置
function Deal(){
	global $DB,$mudi,$menuFileID,$menuTreeID;

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

	$adminLoginKey		= OT::PostStr('adminLoginKey');
	$isAutoLogin		= OT::PostInt('isAutoLogin');
	$skinWidth			= OT::PostInt('skinWidth');
	$userSaveMode		= OT::PostInt('userSaveMode');
	$loginMode			= OT::PostInt('loginMode');
	$isLan				= OT::PostInt('isLan');
	$sendUrlMode		= OT::PostInt('sendUrlMode');
	$checkUrlMode		= OT::PostInt('checkUrlMode');
	$updateUrlMode		= OT::PostInt('updateUrlMode');
	$exitMinute			= OT::PostInt('exitMinute');
	$leftMenuNote		= OT::PostStr('leftMenuNote');
	$editorMode			= OT::PostStr('editorMode');
		if (! in_array($editorMode, array('tinymce','tinymce5','kindeditor4','kindeditor3','ckeditor4','ckeditor3','fckeditor','ueditor'))){
			$editorMode = 'kindeditor4';
		}
	$memberLogRank		= OT::PostInt('memberLogRank');
	$updateUrl			= OT::PostStr('updateUrl');
	$copyrightName		= OT::PostStr('copyrightName');
	$copyrightUrl		= OT::PostStr('copyrightUrl');
		if (strlen($copyrightUrl) == 0){ $copyrightUrl='http://'; }
	$getUrlMode			= OT::PostInt('getUrlMode');
	$collUrlMode		= OT::PostInt('collUrlMode');
	$softUpdateDay		= OT::PostInt('softUpdateDay');
	$softVerUpdateDay	= OT::PostInt('softVerUpdateDay');
	$isConnInternet		= OT::PostInt('isConnInternet');
	$isAnnounShow		= OT::PostInt('isAnnounShow');
	$backupCallDay		= OT::PostInt('backupCallDay');
	$isSubMenu			= OT::PostInt('isSubMenu');
	$upFileArea			= OT::PostStr('upFileArea');
	$upFileOss			= OT::PostStr('upFileOss');
		if ($upFileOss == ''){ $upFileOss = 'web'; }
	$workOrderSec		= OT::PostInt('workOrderSec');
	$workOrderEvent		= OT::Post('workOrderEvent');
		if (is_array($workOrderEvent)){ $workOrderEvent = implode(',',$workOrderEvent); }
	$upFileExtList		= OT::PostStr('upFileExtList');
	$event				= OT::PostArrStr('event', ',');
	$tplDir				= OT::PostStr('tplDir');
	$menuMode			= OT::PostInt('menuMode');
	$autoLoginKey		= OT::PostStr('autoLoginKey');
	$infoCloseArea		= OT::PostArrStr('infoCloseArea', ',');
	$funcCloseArea		= OT::PostArrStr('funcCloseArea', ',');
	$skinWidth2			= OT::PostInt('skinWidth2');

	if ($backURL=='' || $adminLoginKey==''){
		JS::AlertBackEnd('表单内容接收不全');
	}

	$record=array();
	$record['SA_adminLoginKey']		= $adminLoginKey;
	$record['SA_isAutoLogin']		= $isAutoLogin;
	$record['SA_skinWidth']			= $skinWidth;
	$record['SA_userSaveMode']		= $userSaveMode;
	$record['SA_loginMode']			= $loginMode;
	$record['SA_isLan']				= $isLan;
	$record['SA_sendUrlMode']		= $sendUrlMode;
	$record['SA_checkUrlMode']		= $checkUrlMode;
	$record['SA_updateUrlMode']		= $updateUrlMode;
	$record['SA_exitMinute']		= $exitMinute;
	$record['SA_leftMenuNote']		= $leftMenuNote;
	$record['SA_memberLogRank']		= $memberLogRank;
	$record['SA_softUpdateDay']		= $softUpdateDay;
	$record['SA_softVerUpdateDay']	= $softVerUpdateDay;
	$record['SA_isConnInternet']	= $isConnInternet;
	$record['SA_isAnnounShow']		= $isAnnounShow;
	$record['SA_backupCallDay']		= $backupCallDay;
	$record['SA_getUrlMode']		= $getUrlMode;
	$record['SA_collUrlMode']		= $collUrlMode;
	$record['SA_copyrightName']		= $copyrightName;
	$record['SA_copyrightUrl']		= $copyrightUrl;
	$record['SA_editorMode']		= $editorMode;
	$record['SA_updateUrl']			= $updateUrl;
	$record['SA_isSubMenu']			= $isSubMenu;
	// $record['SA_upFileArea']		= $upFileArea;
	$record['SA_upFileOss']			= $upFileOss;
	$record['SA_workOrderSec']		= $workOrderSec;
	$record['SA_workOrderEvent']	= $workOrderEvent;
	$record['SA_upFileExtList']		= $upFileExtList;
	$record['SA_event']				= $event;
	$record['SA_tplDir']			= $tplDir;
	$record['SA_menuMode']			= $menuMode;
	$record['SA_autoLoginKey']		= $autoLoginKey;
	$record['SA_infoCloseArea']		= $infoCloseArea;
	$record['SA_funcCloseArea']		= $funcCloseArea;
	$record['SA_skinWidth2']		= $skinWidth2;

	$fileResStr = '';
	$judRes = $DB->UpdateParam('sysAdmin',$record,'SA_ID=1');
		if ($judRes){
			$alertRes = '成功';

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

	Adm::AddLog(array(
		'note'		=> '【后台参数设置】修改'. $alertRes .'！',
		));

	JS::AlertHrefEnd('修改'. $alertRes .'.'. $fileResStr,$backURL);
}



// 模式、路线恢复默认值
function SaveDef(){
	global $DB,$mudi,$menuFileID,$menuTreeID;

	$backURL = OT::GetStr('backURL');
		if ($backURL == ''){ $backURL='sysAdmin.php?mudi='; }

	$record=array();
	$record['SA_sendUrlMode']		= 0;
	$record['SA_checkUrlMode']		= 0;
	$record['SA_updateUrlMode']		= 0;
	$record['SA_getUrlMode']		= 0;
	$record['SA_collUrlMode']		= 0;

	$fileResStr = '';
	$judRes = $DB->UpdateParam('sysAdmin',$record,'SA_ID=1');
		if ($judRes){
			$alertRes = '成功';

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

	Adm::AddLog(array(
		'note'		=> '【后台参数设置】模式、路线恢复默认值'. $alertRes .'！',
		));

	JS::AlertHrefEnd('模式、路线恢复默认值'. $alertRes .'.'. $fileResStr,$backURL);
}



// 菜单网址简化
function MenuUrlSimp(){
	global $DB,$mudi,$menuFileID,$menuTreeID;

	$backURL = OT::GetStr('backURL');
		if ($backURL == ''){ $backURL='sysAdmin.php?mudi='; }

	$succNum = $failNum = 0;
	$loadexe = $DB->query('select MT_ID,MT_getImgStr,MT_URL from '. OT_dbPref .'menuTree');
	while ($row = $loadexe->fetch()){
		$record = array();
		$record['MT_getImgStr'] = '';	// &isImgWH=0&imgWHread=0&imgW=0&imgH=0&isImgWater=0&imgWaterW=&imgWaterH=&imgWaterName=
		$url = str_replace(array('&dataMode=&','&dataModeStr=&','&dataType=&','&dataType2=&','&dataID=0'), array('&','&','&','&',''), $row['MT_URL'] .'');
		$record['MT_URL'] = $url;
		$resJud = $DB->UpdateParam('menuTree',$record,'MT_ID='. $row['MT_ID']);
		if ($resJud){ $succNum ++; }else{ $failNum ++; }
	}
	unset($loadexe);

	Adm::AddLog(array(
		'note'		=> '【后台参数设置】菜单网址简化（成功'. $succNum .'条，失败'. $failNum .'条）',
		));

	JS::AlertHrefEnd('菜单网址简化（成功'. $succNum .'条，失败'. $failNum .'条）.',$backURL);
}
?>