<?php
require(dirname(__FILE__) .'/check.php');


switch ($mudi){
	case 'updateWebCache':
		UpdateWebCache();
		break;

	case 'clearWebCache':
		ClearWebCache();
		break;

	case 'updateBackupCall':
		UpdateBackupCall();
		break;

	case 'checkEditorMode':
		CheckEditorMode();
		break;

	case 'readQrCode':
		ReadQrCode();
		break;

	case 'checkHomeHtml':
		CheckHomeHtml();
		break;

	default:
		die('err');
}

$DB->Close();





function UpdateWebCache(){
	global $DB,$dbName;

	$mode = OT::GetStr('mode');
	if ($mode == 'verCodeNum'){
		$DB->query('update '. OT_dbPref .'system set SYS_verCodeMode=1 where SYS_ID=1');

	}elseif ($mode == 'defTpl'){
		$DB->query('update '. OT_dbPref .'system set SYS_templateDir="default/" where SYS_ID=1');

	}elseif ($mode == 'showDb'){
		echo('<div>服务器类型：'. PHP_OS .'&ensp;&ensp;&ensp;&ensp;服务器端信息：'. $_SERVER['SERVER_SOFTWARE'] .'/'. OT_VERSION .'</div>');
		$tabNum = 0;
		$sizeexe = $DB->query("select TABLE_NAME from information_schema.tables where TABLE_SCHEMA = '". $dbName ."'");
			while ($row = $sizeexe->fetch()){
				$tabNum ++;
				echo('<div>'. str_replace(OT_dbPref,'前缀_',$row['TABLE_NAME']) .'（'. $DB->GetOne('select count(1) from '. $row['TABLE_NAME'] .'') .'）</div>');
			}
		unset($sizeexe);
		die('<div>共 <b>'. $tabNum .'</b> 张表</div>');

	}elseif ($mode == 'revTabName'){
		$mudi2 = OT::GetStr('mudi2');

		$prefl = strtolower(OT_dbPref);
		$DB->query("ALTER TABLE ". $prefl ."actsys RENAME TO ". OT_dbPref ."actSys");
		$DB->query("ALTER TABLE ". $prefl ."ad RENAME TO ". OT_dbPref ."ad");
		$DB->query("ALTER TABLE ". $prefl ."apirecord RENAME TO ". OT_dbPref ."apiRecord");
		$DB->query("ALTER TABLE ". $prefl ."appsys RENAME TO ". OT_dbPref ."appSys");
		$DB->query("ALTER TABLE ". $prefl ."autorunlog RENAME TO ". OT_dbPref ."autoRunLog");
		$DB->query("ALTER TABLE ". $prefl ."autorunsys RENAME TO ". OT_dbPref ."autoRunSys");
		$DB->query("ALTER TABLE ". $prefl ."banner RENAME TO ". OT_dbPref ."banner");
		$DB->query("ALTER TABLE ". $prefl ."bbsdata RENAME TO ". OT_dbPref ."bbsData");
		$DB->query("ALTER TABLE ". $prefl ."bbsreply RENAME TO ". OT_dbPref ."bbsReply");
		$DB->query("ALTER TABLE ". $prefl ."bbssys RENAME TO ". OT_dbPref ."bbsSys");
		$DB->query("ALTER TABLE ". $prefl ."bbstype RENAME TO ". OT_dbPref ."bbsType");
		$DB->query("ALTER TABLE ". $prefl ."buyorders RENAME TO ". OT_dbPref ."buyOrders");
		$DB->query("ALTER TABLE ". $prefl ."buysys RENAME TO ". OT_dbPref ."buySys");
		$DB->query("ALTER TABLE ". $prefl ."collhistory RENAME TO ". OT_dbPref ."collHistory");
		$DB->query("ALTER TABLE ". $prefl ."collitem RENAME TO ". OT_dbPref ."collItem");
		$DB->query("ALTER TABLE ". $prefl ."collresult RENAME TO ". OT_dbPref ."collResult");
		$DB->query("ALTER TABLE ". $prefl ."collsys RENAME TO ". OT_dbPref ."collSys");
		$DB->query("ALTER TABLE ". $prefl ."colltype RENAME TO ". OT_dbPref ."collType");
		$DB->query("ALTER TABLE ". $prefl ."dashang RENAME TO ". OT_dbPref ."dashang");
		$DB->query("ALTER TABLE ". $prefl ."dbbak RENAME TO ". OT_dbPref ."dbBak");
		$DB->query("ALTER TABLE ". $prefl ."dberr RENAME TO ". OT_dbPref ."dbErr");
		$DB->query("ALTER TABLE ". $prefl ."filedata RENAME TO ". OT_dbPref ."fileData");
		$DB->query("ALTER TABLE ". $prefl ."filever RENAME TO ". OT_dbPref ."fileVer");
		$DB->query("ALTER TABLE ". $prefl ."formfield RENAME TO ". OT_dbPref ."formField");
		$DB->query("ALTER TABLE ". $prefl ."formtype RENAME TO ". OT_dbPref ."formType");
		$DB->query("ALTER TABLE ". $prefl ."formusers RENAME TO ". OT_dbPref ."formUsers");
		$DB->query("ALTER TABLE ". $prefl ."gainhistory RENAME TO ". OT_dbPref ."gainHistory");
		$DB->query("ALTER TABLE ". $prefl ."gainitem RENAME TO ". OT_dbPref ."gainItem");
		$DB->query("ALTER TABLE ". $prefl ."gainmoney RENAME TO ". OT_dbPref ."gainMoney");
		$DB->query("ALTER TABLE ". $prefl ."giftdata RENAME TO ". OT_dbPref ."giftData");
		$DB->query("ALTER TABLE ". $prefl ."giftsys RENAME TO ". OT_dbPref ."giftSys");
		$DB->query("ALTER TABLE ". $prefl ."giftusers RENAME TO ". OT_dbPref ."giftUsers");
		$DB->query("ALTER TABLE ". $prefl ."gourl RENAME TO ". OT_dbPref ."goUrl");
		$DB->query("ALTER TABLE ". $prefl ."gourlbrowser RENAME TO ". OT_dbPref ."goUrlBrowser");
		$DB->query("ALTER TABLE ". $prefl ."gourlusers RENAME TO ". OT_dbPref ."goUrlUsers");
		$DB->query("ALTER TABLE ". $prefl ."htmlfile RENAME TO ". OT_dbPref ."htmlFile");
		$DB->query("ALTER TABLE ". $prefl ."idcprodata RENAME TO ". OT_dbPref ."idcProData");
		$DB->query("ALTER TABLE ". $prefl ."idcprosys RENAME TO ". OT_dbPref ."idcProSys");
		$DB->query("ALTER TABLE ". $prefl ."idcprotype RENAME TO ". OT_dbPref ."idcProType");
		$DB->query("ALTER TABLE ". $prefl ."info RENAME TO ". OT_dbPref ."info");
		$DB->query("ALTER TABLE ". $prefl ."infocontent1 RENAME TO ". OT_dbPref ."infoContent1");
		$DB->query("ALTER TABLE ". $prefl ."infocontent2 RENAME TO ". OT_dbPref ."infoContent2");
		$DB->query("ALTER TABLE ". $prefl ."infocontent3 RENAME TO ". OT_dbPref ."infoContent3");
		$DB->query("ALTER TABLE ". $prefl ."infocontent4 RENAME TO ". OT_dbPref ."infoContent4");
		$DB->query("ALTER TABLE ". $prefl ."infocontent5 RENAME TO ". OT_dbPref ."infoContent5");
		$DB->query("ALTER TABLE ". $prefl ."infocontent6 RENAME TO ". OT_dbPref ."infoContent6");
		$DB->query("ALTER TABLE ". $prefl ."infocontent7 RENAME TO ". OT_dbPref ."infoContent7");
		$DB->query("ALTER TABLE ". $prefl ."infocontent8 RENAME TO ". OT_dbPref ."infoContent8");
		$DB->query("ALTER TABLE ". $prefl ."infocontent9 RENAME TO ". OT_dbPref ."infoContent9");
		$DB->query("ALTER TABLE ". $prefl ."infocontent10 RENAME TO ". OT_dbPref ."infoContent10");
		$DB->query("ALTER TABLE ". $prefl ."infocontent11 RENAME TO ". OT_dbPref ."infoContent11");
		$DB->query("ALTER TABLE ". $prefl ."infocontent12 RENAME TO ". OT_dbPref ."infoContent12");
		$DB->query("ALTER TABLE ". $prefl ."infocontent13 RENAME TO ". OT_dbPref ."infoContent13");
		$DB->query("ALTER TABLE ". $prefl ."infocontent14 RENAME TO ". OT_dbPref ."infoContent14");
		$DB->query("ALTER TABLE ". $prefl ."infocontent15 RENAME TO ". OT_dbPref ."infoContent15");
		$DB->query("ALTER TABLE ". $prefl ."infocontent16 RENAME TO ". OT_dbPref ."infoContent16");
		$DB->query("ALTER TABLE ". $prefl ."infocontent17 RENAME TO ". OT_dbPref ."infoContent17");
		$DB->query("ALTER TABLE ". $prefl ."infocontent18 RENAME TO ". OT_dbPref ."infoContent18");
		$DB->query("ALTER TABLE ". $prefl ."infocontent19 RENAME TO ". OT_dbPref ."infoContent19");
		$DB->query("ALTER TABLE ". $prefl ."infocontent20 RENAME TO ". OT_dbPref ."infoContent20");
		$DB->query("ALTER TABLE ". $prefl ."infocontent21 RENAME TO ". OT_dbPref ."infoContent21");
		$DB->query("ALTER TABLE ". $prefl ."infocontent22 RENAME TO ". OT_dbPref ."infoContent22");
		$DB->query("ALTER TABLE ". $prefl ."infocontent23 RENAME TO ". OT_dbPref ."infoContent23");
		$DB->query("ALTER TABLE ". $prefl ."infocontent24 RENAME TO ". OT_dbPref ."infoContent24");
		$DB->query("ALTER TABLE ". $prefl ."infocontent25 RENAME TO ". OT_dbPref ."infoContent25");
		$DB->query("ALTER TABLE ". $prefl ."infocontent26 RENAME TO ". OT_dbPref ."infoContent26");
		$DB->query("ALTER TABLE ". $prefl ."infocontent27 RENAME TO ". OT_dbPref ."infoContent27");
		$DB->query("ALTER TABLE ". $prefl ."infocontent28 RENAME TO ". OT_dbPref ."infoContent28");
		$DB->query("ALTER TABLE ". $prefl ."infocontent29 RENAME TO ". OT_dbPref ."infoContent29");
		$DB->query("ALTER TABLE ". $prefl ."infocontent30 RENAME TO ". OT_dbPref ."infoContent30");
		$DB->query("ALTER TABLE ". $prefl ."infodown RENAME TO ". OT_dbPref ."infoDown");
		$DB->query("ALTER TABLE ". $prefl ."infomessage RENAME TO ". OT_dbPref ."infoMessage");
		$DB->query("ALTER TABLE ". $prefl ."infomove RENAME TO ". OT_dbPref ."infoMove");
		$DB->query("ALTER TABLE ". $prefl ."infosys RENAME TO ". OT_dbPref ."infoSys");
		$DB->query("ALTER TABLE ". $prefl ."infotheme RENAME TO ". OT_dbPref ."infoTheme");
		$DB->query("ALTER TABLE ". $prefl ."infotype RENAME TO ". OT_dbPref ."infoType");
		$DB->query("ALTER TABLE ". $prefl ."infoview RENAME TO ". OT_dbPref ."infoView");
		$DB->query("ALTER TABLE ". $prefl ."infoweb RENAME TO ". OT_dbPref ."infoWeb");
		$DB->query("ALTER TABLE ". $prefl ."job RENAME TO ". OT_dbPref ."job");
		$DB->query("ALTER TABLE ". $prefl ."jobuser RENAME TO ". OT_dbPref ."jobUser");
		$DB->query("ALTER TABLE ". $prefl ."keyword RENAME TO ". OT_dbPref ."keyWord");
		$DB->query("ALTER TABLE ". $prefl ."mailcode RENAME TO ". OT_dbPref ."mailCode");
		$DB->query("ALTER TABLE ". $prefl ."mailinfo RENAME TO ". OT_dbPref ."mailInfo");
		$DB->query("ALTER TABLE ". $prefl ."mailtpl RENAME TO ". OT_dbPref ."mailTpl");
		$DB->query("ALTER TABLE ". $prefl ."mailusers RENAME TO ". OT_dbPref ."mailUsers");
		$DB->query("ALTER TABLE ". $prefl ."makediy RENAME TO ". OT_dbPref ."makeDiy");
		$DB->query("ALTER TABLE ". $prefl ."member RENAME TO ". OT_dbPref ."member");
		$DB->query("ALTER TABLE ". $prefl ."membergroup RENAME TO ". OT_dbPref ."memberGroup");
		$DB->query("ALTER TABLE ". $prefl ."memberlog RENAME TO ". OT_dbPref ."memberLog");
		$DB->query("ALTER TABLE ". $prefl ."memberonline RENAME TO ". OT_dbPref ."memberOnline");
		$DB->query("ALTER TABLE ". $prefl ."menufile RENAME TO ". OT_dbPref ."menuFile");
		$DB->query("ALTER TABLE ". $prefl ."menutree RENAME TO ". OT_dbPref ."menuTree");
		$DB->query("ALTER TABLE ". $prefl ."message RENAME TO ". OT_dbPref ."message");
		$DB->query("ALTER TABLE ". $prefl ."moneygive RENAME TO ". OT_dbPref ."moneyGive");
		$DB->query("ALTER TABLE ". $prefl ."moneypay RENAME TO ". OT_dbPref ."moneyPay");
		$DB->query("ALTER TABLE ". $prefl ."moneyquick RENAME TO ". OT_dbPref ."moneyQuick");
		$DB->query("ALTER TABLE ". $prefl ."moneyrecord RENAME TO ". OT_dbPref ."moneyRecord");
		$DB->query("ALTER TABLE ". $prefl ."moneysys RENAME TO ". OT_dbPref ."moneySys");
		$DB->query("ALTER TABLE ". $prefl ."moneytime RENAME TO ". OT_dbPref ."moneyTime");
		$DB->query("ALTER TABLE ". $prefl ."onewebtpl RENAME TO ". OT_dbPref ."oneWebTpl");
		$DB->query("ALTER TABLE ". $prefl ."onewebtype RENAME TO ". OT_dbPref ."oneWebType");
		$DB->query("ALTER TABLE ". $prefl ."onewebusers RENAME TO ". OT_dbPref ."oneWebUsers");
		$DB->query("ALTER TABLE ". $prefl ."paysoft RENAME TO ". OT_dbPref ."paySoft");
		$DB->query("ALTER TABLE ". $prefl ."phonecode RENAME TO ". OT_dbPref ."phoneCode");
		$DB->query("ALTER TABLE ". $prefl ."phonesys RENAME TO ". OT_dbPref ."phoneSys");
		$DB->query("ALTER TABLE ". $prefl ."phonetpl RENAME TO ". OT_dbPref ."phoneTpl");
		$DB->query("ALTER TABLE ". $prefl ."phoneusers RENAME TO ". OT_dbPref ."phoneUsers");
		$DB->query("ALTER TABLE ". $prefl ."provcity RENAME TO ". OT_dbPref ."provCity");
		$DB->query("ALTER TABLE ". $prefl ."qiandaosys RENAME TO ". OT_dbPref ."qiandaoSys");
		$DB->query("ALTER TABLE ". $prefl ."qrcodeimg RENAME TO ". OT_dbPref ."qrcodeImg");
		$DB->query("ALTER TABLE ". $prefl ."quandata RENAME TO ". OT_dbPref ."quanData");
		$DB->query("ALTER TABLE ". $prefl ."quansys RENAME TO ". OT_dbPref ."quanSys");
		$DB->query("ALTER TABLE ". $prefl ."qundata RENAME TO ". OT_dbPref ."qunData");
		$DB->query("ALTER TABLE ". $prefl ."quntype RENAME TO ". OT_dbPref ."qunType");
		$DB->query("ALTER TABLE ". $prefl ."report RENAME TO ". OT_dbPref ."report");
		$DB->query("ALTER TABLE ". $prefl ."robotdata RENAME TO ". OT_dbPref ."robotData");
		$DB->query("ALTER TABLE ". $prefl ."robotnum RENAME TO ". OT_dbPref ."robotNum");
		$DB->query("ALTER TABLE ". $prefl ."robotpr RENAME TO ". OT_dbPref ."robotPR");
		$DB->query("ALTER TABLE ". $prefl ."robotrank RENAME TO ". OT_dbPref ."robotRank");
		$DB->query("ALTER TABLE ". $prefl ."robotsys RENAME TO ". OT_dbPref ."robotSys");
		$DB->query("ALTER TABLE ". $prefl ."sitemessage RENAME TO ". OT_dbPref ."siteMessage");
		$DB->query("ALTER TABLE ". $prefl ."sitemessagereply RENAME TO ". OT_dbPref ."siteMessageReply");
		$DB->query("ALTER TABLE ". $prefl ."sysadmin RENAME TO ". OT_dbPref ."sysAdmin");
		$DB->query("ALTER TABLE ". $prefl ."sysimages RENAME TO ". OT_dbPref ."sysImages");
		$DB->query("ALTER TABLE ". $prefl ."sysparam RENAME TO ". OT_dbPref ."sysParam");
		$DB->query("ALTER TABLE ". $prefl ."system RENAME TO ". OT_dbPref ."system");
		$DB->query("ALTER TABLE ". $prefl ."tag RENAME TO ". OT_dbPref ."tag");
		$DB->query("ALTER TABLE ". $prefl ."taokeapp RENAME TO ". OT_dbPref ."taokeApp");
		$DB->query("ALTER TABLE ". $prefl ."taokegoods RENAME TO ". OT_dbPref ."taokeGoods");
		$DB->query("ALTER TABLE ". $prefl ."taokeitem RENAME TO ". OT_dbPref ."taokeItem");
		$DB->query("ALTER TABLE ". $prefl ."taokeorder RENAME TO ". OT_dbPref ."taokeOrder");
		$DB->query("ALTER TABLE ". $prefl ."taokeorderid RENAME TO ". OT_dbPref ."taokeOrderId");
		$DB->query("ALTER TABLE ". $prefl ."taokeorderusers RENAME TO ". OT_dbPref ."taokeOrderUsers");
		$DB->query("ALTER TABLE ". $prefl ."taokesys RENAME TO ". OT_dbPref ."taokeSys");
		$DB->query("ALTER TABLE ". $prefl ."taoketype RENAME TO ". OT_dbPref ."taokeType");
		$DB->query("ALTER TABLE ". $prefl ."taokeview RENAME TO ". OT_dbPref ."taokeView");
		$DB->query("ALTER TABLE ". $prefl ."taokeword RENAME TO ". OT_dbPref ."taokeWord");
		$DB->query("ALTER TABLE ". $prefl ."taokexianbao RENAME TO ". OT_dbPref ."taokeXianbao");
		$DB->query("ALTER TABLE ". $prefl ."template RENAME TO ". OT_dbPref ."template");
		$DB->query("ALTER TABLE ". $prefl ."tplsys RENAME TO ". OT_dbPref ."tplSys");
		$DB->query("ALTER TABLE ". $prefl ."type RENAME TO ". OT_dbPref ."type");
		$DB->query("ALTER TABLE ". $prefl ."upfile RENAME TO ". OT_dbPref ."upFile");
		$DB->query("ALTER TABLE ". $prefl ."userapi RENAME TO ". OT_dbPref ."userApi");
		$DB->query("ALTER TABLE ". $prefl ."userfile RENAME TO ". OT_dbPref ."userFile");
		$DB->query("ALTER TABLE ". $prefl ."usergroup RENAME TO ". OT_dbPref ."userGroup");
		$DB->query("ALTER TABLE ". $prefl ."userip RENAME TO ". OT_dbPref ."userIp");
		$DB->query("ALTER TABLE ". $prefl ."userlevel RENAME TO ". OT_dbPref ."userLevel");
		$DB->query("ALTER TABLE ". $prefl ."userlog RENAME TO ". OT_dbPref ."userLog");
		$DB->query("ALTER TABLE ". $prefl ."usermark RENAME TO ". OT_dbPref ."userMark");
		$DB->query("ALTER TABLE ". $prefl ."usermoney RENAME TO ". OT_dbPref ."userMoney");
		$DB->query("ALTER TABLE ". $prefl ."useronline RENAME TO ". OT_dbPref ."userOnline");
		$DB->query("ALTER TABLE ". $prefl ."users RENAME TO ". OT_dbPref ."users");
		$DB->query("ALTER TABLE ". $prefl ."userscore RENAME TO ". OT_dbPref ."userScore");
		$DB->query("ALTER TABLE ". $prefl ."usersys RENAME TO ". OT_dbPref ."userSys");
		$DB->query("ALTER TABLE ". $prefl ."usertemp RENAME TO ". OT_dbPref ."userTemp");
		$DB->query("ALTER TABLE ". $prefl ."userview RENAME TO ". OT_dbPref ."userView");
		$DB->query("ALTER TABLE ". $prefl ."wap RENAME TO ". OT_dbPref ."wap");
		$DB->query("ALTER TABLE ". $prefl ."weixinadmin RENAME TO ". OT_dbPref ."weixinAdmin");
		$DB->query("ALTER TABLE ". $prefl ."weixinformfield RENAME TO ". OT_dbPref ."weixinFormField");
		$DB->query("ALTER TABLE ". $prefl ."weixinformtype RENAME TO ". OT_dbPref ."weixinFormType");
		$DB->query("ALTER TABLE ". $prefl ."weixinformusers RENAME TO ". OT_dbPref ."weixinFormUsers");
		$DB->query("ALTER TABLE ". $prefl ."weixininfo RENAME TO ". OT_dbPref ."weixinInfo");
		$DB->query("ALTER TABLE ". $prefl ."weixinlog RENAME TO ". OT_dbPref ."weixinLog");
		$DB->query("ALTER TABLE ". $prefl ."weixinmenu RENAME TO ". OT_dbPref ."weixinMenu");
		$DB->query("ALTER TABLE ". $prefl ."weixinnews RENAME TO ". OT_dbPref ."weixinNews");
		$DB->query("ALTER TABLE ". $prefl ."weixinother RENAME TO ". OT_dbPref ."weixinOther");
		$DB->query("ALTER TABLE ". $prefl ."weixinqrcode RENAME TO ". OT_dbPref ."weixinQrcode");
		$DB->query("ALTER TABLE ". $prefl ."weixinsys RENAME TO ". OT_dbPref ."weixinSys");
		$DB->query("ALTER TABLE ". $prefl ."weixintpl RENAME TO ". OT_dbPref ."weixinTpl");
		$DB->query("ALTER TABLE ". $prefl ."weixintplsend RENAME TO ". OT_dbPref ."weixinTplSend");
		$DB->query("ALTER TABLE ". $prefl ."weixintplset RENAME TO ". OT_dbPref ."weixinTplSet");
		$DB->query("ALTER TABLE ". $prefl ."weixinusergroup RENAME TO ". OT_dbPref ."weixinUserGroup");
		$DB->query("ALTER TABLE ". $prefl ."weixinusers RENAME TO ". OT_dbPref ."weixinUsers");
		$DB->query("ALTER TABLE ". $prefl ."weixinwordcontent RENAME TO ". OT_dbPref ."weixinWordContent");
		$DB->query("ALTER TABLE ". $prefl ."weixinwordkey RENAME TO ". OT_dbPref ."weixinWordKey");
		$DB->query("ALTER TABLE ". $prefl ."workdata RENAME TO ". OT_dbPref ."workData");
		$DB->query("ALTER TABLE ". $prefl ."workusers RENAME TO ". OT_dbPref ."workUsers");
		echo('<div>修改表名大小写完成，现在到数据库管理里看看。'. ($mudi2 == 'db' ? '<a href="sysCheckFile.php?mudi=db" style="color:red;">【返回】</a>' : '') .'</div>');

	}

	$Cache = new Cache();
	$Cache->Php('userSys');
	$Cache->Js('userSys');
	$Cache->Php('infoSys');
	$Cache->Js('infoSys');
	$Cache->Php('sysAdmin');
	$Cache->Php('system');
	$Cache->Js('system');
	$Cache->Php('sysImages');
	$Cache->Php('autoRunSys');
	$Cache->Js('autoRunSys');
	$Cache->Php('appSys');
	$Cache->Js('appSys');
	Cache::UpdateConfigJs();

	if (AppWap::Jud()){
		$DB->query('update '. OT_dbPref .'wap set WAP_htmlCacheTime='. $DB->ForTime(TimeDate::Get()));
		$Cache->Php('wap');
	}
	if (AppBbs::Jud()){
		$Cache->Php('bbsSys');
	}

	File::DelDir(OT_ROOT .'cache/smarty/templates_c/', false);
	Ad::MakeJs();

	JS::AlertEnd('更新配置缓存文件完成');
}



// 清空缓存
function ClearWebCache(){
	$mode = OT::GetStr('mode');

	$webCacheNum = File::Count(OT_ROOT .'cache/html/',array('html','png'));

	if ($webCacheNum>0){
		$retNum = File::MoreDel(OT_ROOT .'cache/html/',array('html','png'));

		if ($mode != 'noAlert'){
			echo('alert("共清空了'. $retNum .'个缓存。");');
		}
	}else{
		if ($mode != 'noAlert'){
			echo('alert("暂无页面缓存，无需清理。");');
		}
	}
/*
	global $DB;

	$todayTime = TimeDate::Get();
	$DB->query('update '. OT_dbPref .'system set SYS_htmlCacheTime='. $DB->ForTime($todayTime));

	$Cache = new Cache();
	$Cache->Php('system');

	if ($mode != 'noAlert'){
		echo('alert("页面缓存已更新'. $todayTime .'.");');
	}
*/

}



function UpdateBackupCall(){
	global $DB;

	$num = OT::GetInt('num');

	$newDate = '';
	switch ($num){
		case -1:
			$newDate=TimeDate::Get('date');
			break;

		case 1:
			$newDate=TimeDate::Add('d',1-$sysAdminArr['SA_backupCallDay'],TimeDate::Get('date'));
			break;

		case 7:
			$newDate=TimeDate::Add('d',7-$sysAdminArr['SA_backupCallDay'],TimeDate::Get('date'));
			break;

	}
	if (strtotime($newDate)){
		$DB->query('update '. OT_dbPref .'sysAdmin set SA_backupCallTime='. $DB->ForTime($newDate) .' where SA_ID=1');
	}
	
	$Cache = new Cache();
	$Cache->Php('sysAdmin');
}



function CheckEditorMode(){
	$editorMode = OT::GetStr('editorMode');

	switch ($editorMode){
		case 'kindeditor4.x':
			$fileStr = File::Read(OT_adminROOT .'tools/kindeditor4/kindeditor-all-min.js');
			if (strlen($fileStr)<=15){
				die(''.
				'alert("未检测到KindEditor4.x编辑器，请确定存在【后台目录/tools/kindeditor4/】该目录");'.
				'$id("editorMode1").checked=true;'.
				'');
			}
			break;

		case 'kindeditor3.x':
			$fileStr = File::Read(OT_adminROOT .'tools/kindeditor/kindeditor-min.js');
			if (strlen($fileStr)<=15){
				die(''.
				'alert("未检测到KindEditor3.x编辑器，请确定存在【后台目录/tools/kindeditor/】该目录");'.
				'$id("editorMode1").checked=true;'.
				'');
			}
			break;

		case 'ckeditor4.x':
			$fileStr = File::Read(OT_adminROOT .'tools/ckeditor4/ckeditor.js');
			if (strlen($fileStr)<=15){
				die(''.
				'alert("未检测到CKEditor4.x编辑器，请确定存在【后台目录/ckeditor4/】该目录");'.
				'$id("editorMode1").checked=true;'.
				'');
			}
			break;

		case 'ckeditor':
			$fileStr = File::Read(OT_adminROOT .'tools/ckeditor/ckeditor.js');
			if (strlen($fileStr)<=15){
				die(''.
				'alert("未检测到CKEditor3.x编辑器，请确定存在【后台目录/ckeditor/】该目录");'.
				'$id("editorMode1").checked=true;'.
				'');
			}
			break;

		case 'fckeditor':
			$fileStr = File::Read(OT_adminROOT .'tools/fckeditor/fckeditor.js');
			if (strlen($fileStr)<=15){
				die(''.
				'alert("未检测到FCKeditor编辑器，请确定存在【后台目录/fckeditor/】该目录");'.
				'$id("editorMode1").checked=true;'.
				'');
			}
			break;

		case 'ueditor':
			$fileStr = File::Read(OT_adminROOT .'tools/ueditor/ueditor.config.js');
			if (strlen($fileStr)<=15){
				die(''.
				'alert("未检测到ueditor编辑器，请确定存在【后台目录/tools/ueditor/】该目录");'.
				'$id("editorMode1").checked=true;'.
				'');
			}
			break;

		default :
			die(''.
			'alert("未知编辑器.");'.
			'$id("editorMode1").checked=true;'.
			'');
	}
}


function ReadQrCode(){
	$dir = OT::GetStr('dir');
	$img = OT::GetStr('img');
	if (strlen($img) == 0){ die('二维码图片路径为空'); }
	if (! Is::HttpUrl($img)){
		$img = StrInfo::FilePath($dir, $img);
		if (! file_exists($img)){ die('二维码图片不存在('. $img .')'); }
	}

	include_once(OT_ROOT .'inc/QrReader/QrReader.php');
	$qrcode = new QrReader($img);	// 图片路径
	$text = $qrcode->text();		//返回识别后的文本
	if (strlen($text) == 0){ die('二维码图片识别不了'); }
	die($text);
}


function CheckHomeHtml(){
	$beforeURL	= GetUrl::CurrDir(1);
	$webHtml = new WebHtml();
	$homeHtmlStr = $webHtml->GetCode($beforeURL);
	if (strpos($homeHtmlStr,'<!-- Html For') !== false){
		JS::AlertEnd('网站首页是静态页.');
	}else{
		JS::AlertEnd('网站首页不是静态页.\n1、检查前台index.html文件是否存在。\n2、首页默认页index.html要优先于index.php');
	}
}

?>