<?php
require('../../../Interface/Common/Component/ComInitialHead.php');
require($netsFileConfig['sysCoreRoot_Real'].'Cache/DbDescription/Servicesaleorder.php');
require($netsFileConfig['sysCoreRoot_Real'].'Cache/DbDescription/Servicesaleordercont.php');
require($netsFileConfig['sysCoreRoot_Real'].'Cache/DbDescription/netssyschildsiterecord.php');
require($netsFileConfig['sysCoreRoot_Real'].'Cache/DbDescription/netssyschildsiterecordcont.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Servicesale/Servicesale/Servicesaleorder.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Nets/System/netssyschildsiterecord.php');
require($netsFileConfig['sysCoreRoot'].'Inc/netsFunc/Func/netsXml.php');


class PaDefault extends CustomPage {
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		//-- ------ #ActionType ------ --

	}
	public function OnList(){
		$tmpXml=new netsXml();
		$tmpCONTENT=array();
		
		$tmpApp=new Servicesaleorder($this->sConnString);
		$tmpDbDescriptions=array(
			$this->sDbDescriptions[$this->sysTableHead.'servicesaleorder'],
			$this->sDbDescriptions[$this->sysTableHead.'servicesaleordercont'],
			);

		$tmpAR0=$this->AnalyerRequest('Numcode','',0);
		$tmpNumcode_STR=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('Host','',0);
		$tmpHost_STR=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('Code','',0);
		$tmpCode_STR=$tmpAR0[0];
		$tmpErrorCode='SUCCESS';
		$tmpMessage='网集软件系统服务认证成功';
		
		//-- ### --
		$tmpSQL=' SELECT A.sesptID AS ID,
			A.sesptNumCode AS NumCode,
			A.sesptState AS State,
			A.sesptTime_Start AS Time_Start,
			A.sesptTime_End AS Time_End,
			A.sesptInfo_Appname AS Info_Appname,
			A.sesptInfo_Appsite AS Info_Appsite
			FROM {Nets.TableHead}servicesalepower AS A
			WHERE 1=1 AND A.sesptRecycle=0 AND A.sesptChecked>1 AND A.sesptNumCode LIKE \'{Nets.NumCode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.NumCode}',$tmpNumcode_STR,$tmpSTR);
		$tmpData_Power=$this->sDb->Search($tmpSTR);
		if (count($tmpData_Power)==1) {
		}else {
			$tmpData_Power=array(array(
				'ID'=>'',
				'NumCode'=>'',
				'State'=>0,
				'Time_Start'=>'',
				'Time_End'=>'',
				'Info_Appname'=>'',
				'Info_Appsite'=>'',
				));
			$tmpErrorCode='ERROR';
			$tmpMessage='系统认证错误：您提交的服务认证信息不正确(用户NUMCODE)';
			$tmpCONTENT[]=array($tmpErrorCode,1,$tmpData_Power,$tmpMessage,);
			$this->sMainData=$tmpXml->makeNETSXML($tmpCONTENT);
			return 1;
		}
		//-- ### --
		$tmpData_Power[0]['Info_Appsite']='http://';
		$tmpPxdCode=$this->sCode->SamplePxd(
			$tmpData_Power[0]['NumCode'].
			$tmpData_Power[0]['Info_Appname'].
			$tmpData_Power[0]['Info_Appsite']
			);
		if ($tmpCode_STR!=$tmpPxdCode) {
			$tmpData_Power=array(array(
				'ID'=>'',
				'NumCode'=>'',
				'State'=>0,
				'Time_Start'=>'',
				'Time_End'=>'',
				'Info_Appname'=>'',
				'Info_Appsite'=>'',
				));
			$tmpErrorCode='ERROR';
			$tmpMessage='系统认证错误：您提交的服务认证信息不正确(加密码不正确)';
			$tmpCONTENT[]=array($tmpErrorCode,1,$tmpData_Power,$tmpMessage,);
			$this->sMainData=$tmpXml->makeNETSXML($tmpCONTENT);
			return 1;
		}
		//-- ### --
		$tmpDbDescriptions[0]['Columns']['sesptNumCode']['Value']=$tmpData_Power[0]['NumCode'];
		$tmpDbDescriptions[0]['Columns']['sesptState']['Value']=$tmpData_Power[0]['State'];
		$tmpDbDescriptions[0]['Columns']['sesptInfo_Appname']['Value']=$tmpData_Power[0]['Info_Appname'];
		$tmpDbDescriptions[0]['Columns']['sesptInfo_Appsite']['Value']=$tmpData_Power[0]['Info_Appsite'];
		$tmpINT=$tmpApp->service_CheckDatetime($tmpDbDescriptions);
		if ($tmpINT!=0) {
			$tmpData_Power=array(array(
				'ID'=>'',
				'NumCode'=>'',
				'State'=>0,
				'Time_Start'=>'',
				'Time_End'=>'',
				'Info_Appname'=>'',
				'Info_Appsite'=>'',
				));
			$tmpErrorCode='ERROR';
			$tmpMessage='系统认证错误：您提交的服务认证信息不正确('.$tmpApp->sysLastError.')';
			$tmpCONTENT[]=array($tmpErrorCode,1,$tmpData_Power,$tmpMessage,);
			$this->sMainData=$tmpXml->makeNETSXML($tmpCONTENT);
			return 1;
		}
		//-- ### --
		if ($tmpData_Power[0]['State']==1) {
			$tmpData_Power[0]['State']=$tmpDbDescriptions[0]['Columns']['sesptState']['Value'];
		}else {
			$tmpData_Power=array(array(
				'ID'=>'',
				'NumCode'=>'',
				'State'=>0,
				'Time_Start'=>'',
				'Time_End'=>'',
				'Info_Appname'=>'',
				'Info_Appsite'=>'',
				));
			$tmpErrorCode='ERROR';
			$tmpMessage='系统认证错误：您提交的服务认证信息不正确(您的服务已过期)';
			$tmpCONTENT[]=array($tmpErrorCode,1,$tmpData_Power,$tmpMessage,);
			$this->sMainData=$tmpXml->makeNETSXML($tmpCONTENT);
			return 1;
		}
		//-- ------ #Record ------ --
		$tmpDbDescriptions=array(
			$this->sDbDescriptions[$this->sysTableHead.'netssyschildsiterecord'],
			$this->sDbDescriptions[$this->sysTableHead.'netssyschildsiterecordcont'],
			);
		$tmpApp=new netssyschildsiterecord($this->sConnString);
		
		$tmpApp->TransStart();
		//#Get numCode
		$tmpSTR='scsrtNumCode';
		$tmpDbDescriptions[0]['TableDescription']['SearchColumn']=$tmpSTR;
		$tmpDbDescriptions[0]['Columns'][$tmpSTR]['Value']='N'.$this->sysSPLIT11.date('YmdHis');
		$tmpApp->numCode($tmpDbDescriptions[0]);
		//#Set value
		$tmpDbDescriptions[0]['Columns']['scsrtName']['Value']=$tmpDbDescriptions[0]['Columns']['scsrtNumCode']['Value'];
		$tmpDbDescriptions[0]['Columns']['scsrtURL']['Value']=$this->sCode->URL_DecodeParameter($tmpHost_STR,1);
		$tmpDbDescriptions[0]['Columns']['scsrtCreateTime']['Value']=date($this->sysTimeFormat);
		$tmpDbDescriptions[1]['Columns']['scsrctContent']['Value']=$tmpNumcode_STR;
		
		//-- #Set spical --
		
		//#Add
		$tmpINT=$tmpApp->Check($tmpDbDescriptions,array(),array());
		if($tmpINT!=0){
			$tmpApp->TransRollback();
			$tmpData_Power=array(array(
				'ID'=>'',
				'NumCode'=>'',
				'State'=>0,
				'Time_Start'=>'',
				'Time_End'=>'',
				'Info_Appname'=>'',
				'Info_Appsite'=>'',
				));
			$tmpErrorCode='ERROR';
			$tmpMessage='系统认证错误：系统错误，请稍后再试或与客服人员联系。';
			$tmpCONTENT[]=array($tmpErrorCode,1,$tmpData_Power,$tmpMessage,);
			$this->sMainData=$tmpXml->makeNETSXML($tmpCONTENT);
			return 1;
		}
		$tmpDbDescriptions[0]['TableDescription']['SearchColumn']='scsrtNumCode,scsrtID';
		$tmpDbDescriptions[1]['TableDescription']['SearchColumn']='scsrctIndexID';
		$tmpINT=$tmpApp->add($tmpDbDescriptions);
		if($tmpINT!=0){
			$tmpApp->TransRollback();
			$tmpData_Power=array(array(
				'ID'=>'',
				'NumCode'=>'',
				'State'=>0,
				'Time_Start'=>'',
				'Time_End'=>'',
				'Info_Appname'=>'',
				'Info_Appsite'=>'',
				));
			$tmpErrorCode='ERROR';
			$tmpMessage='系统认证错误：系统错误，请稍后再试或与客服人员联系。';
			$tmpCONTENT[]=array($tmpErrorCode,1,$tmpData_Power,$tmpMessage,);
			$this->sMainData=$tmpXml->makeNETSXML($tmpCONTENT);
			return 1;
		}
		$tmpApp->TransCommit();

		//-- ------ #MakeXml ------ --
		$tmpCONTENT=array();
		$tmpCONTENT[]=array($tmpErrorCode,1,$tmpData_Power,$tmpMessage,);
		$this->sMainData=$tmpXml->makeNETSXML($tmpCONTENT);
		return 0;
	}
	
}
//-- ------ #Instanct ------ --
$tmpDefault=new PaDefault();
$tmpDefault->sysMetaTitle=$tmpDefault->sMetaTitle.' - '.$tmpDefault->sysFileConfig['sysTitle'];
//-- ------ #Template ------ --
require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysInterfaceTemplatePath.'Component/Head_Xml.php');
if($tmpDefault->sActionType=='Error'){
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysInterfaceTemplatePath.'Common/normal_xml.php');
}else {
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysInterfaceTemplatePath.'Common/normal_xml.php');
}
require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysInterfaceTemplatePath.'Component/End_Xml.php'); ?>