<?php
require('../../../QPlatform/Common/Component/ComInitialHead.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/netsSimpleXml.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Oa/Oa/oanotebook.php');


class PaDefault extends CustomPage {
	public $sSystem_OS_STR='';
	public $sSystem_PHP_STR='';
	public $sSystem_MYSQL_STR='';
	public $sSystem_DiskSize_STR='';
	public $sSystem_UploadSize_STR='2MB';
	public $sPATH='QPlatform/';
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnPInitial(){
		$this->checkUser('1,2,3,');
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'oanotebook','sttColumnHead'=>'onbt'),
			array('sttTableName'=>$this->sysTableHead.'oanotebookcont','sttColumnHead'=>'onbct'),);
	}
	public function OnBInitial(){
		$this->sMetaTitle='平台首页';
		$this->sApp=new oanotebook($this->sConnString);
		//-- ------ #ActionType ------ --
		if ($this->sActionType=='DAdd_Get') {
			$this->OnAdd_Get();
		}else if ($this->sActionType=='DGetNotes') {
			$this->OnNotes();
		}else if ($this->sActionType=='DGetNews') {
			$this->OnNews();
		}else if ($this->ActionType='DPowerCheck') {
			$this->OnPowerCheck();
		}
		
	}
	public function OnAdd_Get(){
		$tmpDbDescriptions=array();
		foreach ($this->sTable as $tableCell){
			$tmpDbDescriptions[]=$this->sDbDescriptions[$tableCell['sttTableName']];
		}
		$tmpMainid=$this->AnalyerRequest('mainID',0,1);
		$this->sMainID=$tmpMainid[0];
		$tmpMainUserid=$this->AnalyerRequest('mainUserid',0,1);
		$this->sMainUserid=$tmpMainid[0];
		$tmpMainTableid=$this->AnalyerRequest('mainTableid',0,1);
		$this->sMainTableid=$tmpMainid[0];
		//-- ------ #Add ------ --
		$this->sApp->TransStart();
		//#Get numCode
		$tmpSTR=$this->sTable[0]['sttColumnHead'].'NumCode';
		$tmpDbDescriptions[0]['TableDescription']['SearchColumn']=$tmpSTR;
		$tmpDbDescriptions[0]['Columns'][$tmpSTR]['Value']='N_'.date('YmdHis');
		$this->sApp->numCode($tmpDbDescriptions[0]);
		//#Set value
		$tmpDbDescription0=$tmpDbDescriptions;
		$Coun0=0;
		foreach ($tmpDbDescription0 as $tableCell){
			foreach ($tableCell['Columns'] as $Column){
				if($Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'ID' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'NumCode' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'CreateBy' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'CreateTime' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'IndexID'){
					$tmpAR0=$this->AnalyerRequest($Column['stcotName'].'Txt',$Column['stcoctDefaultValue'],1);
					$tmpDbDescriptions[$Coun0]['Columns'][$Column['stcotName']]['Value']=$tmpAR0[0];
				}
			}
			$Coun0++;
		}
		//-- #Set conventional --
		if(isset($tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value'])){
			$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value']=$tmpMainUserid[0];
		}
		if(isset($tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateTime'])){
			$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateTime']['Value']=date($this->sysTimeFormat);
		}
		//DB name,Condition,User index,User column name
		$tmpFlag=0;
		foreach ($this->AnonymousUserData as $Row0){
			if (count($tmpDbDescriptions)>1) {
				if(isset($tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]])){
					if ($tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]]['Value']==$Row0[1]) {
						$tmpFlag=1;
					}
				}
			}
			if ($this->sUserInfo[0]['Columns']['uitID']['Value']==0 && $tmpFlag==1) {
				$tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]]['Value']=$Row0[4];
			}else if ($tmpFlag==1 && isset($tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]])) {
				$tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]]['Value']=$this->sUserInfo[$Row0[2]]['Columns'][$Row0[3]]['Value'];
			}
		}
		//Spical value array
		foreach ($this->sSpicalValue as $Cell){
			if(isset($tmpDbDescriptions[$Cell[0]]['Columns'][$Cell[1]]['Value'])){
				$tmpDbDescriptions[$Cell[0]]['Columns'][$Cell[1]]['Value']=$Cell[2];
			}
		}
		//-- #Set spical --
		$tmpAR0=$this->AnalyerRequest('DAdd_Get','',0);
		$tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].'Content']['Value']=$tmpAR0[0];
		$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'Name']['Value']=$this->sCode->SubString($tmpAR0[0],0,48);
		$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value']=$this->sUserInfo[0]['Columns']['uitID']['Value'];
		
		//#Add
		$tmpINT=$this->sApp->Check($tmpDbDescriptions,array(),array());
		if($tmpINT!=0){
			$this->sApp->TransRollback();
			$this->sMessage=$this->sApp->sysLastError;
			return 1;
		}
		$Coun0=0;
		while (count($tmpDbDescriptions)>$Coun0){
			if($Coun0==0){
				$tmpDbDescriptions[$Coun0]['TableDescription']['SearchColumn']=$this->sTable[$Coun0]['sttColumnHead'].'NumCode,'.$this->sTable[$Coun0]['sttColumnHead'].'ID';
			}else {
				$tmpDbDescriptions[$Coun0]['TableDescription']['SearchColumn']=$this->sTable[$Coun0]['sttColumnHead'].'IndexID';
			}
			$Coun0++;
		}
		$tmpINT=$this->sApp->add($tmpDbDescriptions);
		if($tmpINT!=0){
			$this->sApp->TransRollback();
			$this->sMessage=$this->sApp->sysLastError;
			return 1;
		}
		
		foreach ($this->sDb->sysDbCacheClear as $Cell){
			$this->clearCache($Cell);
		}
		foreach ($this->sysPageCacheClear as $Cell){
			$this->clearCache($Cell);
		}
		$this->sApp->TransCommit();
		
		$this->sMessage='您的记事信息已经保存成功。';
		$this->sJscript=$this->Message('ERROR','',$this->sMessage,'');
		return 0;
	}
	public function OnList(){
		//-- #Server config --
		$this->sSystem_OS_STR=PHP_OS.'.'.$_SERVER['SERVER_SOFTWARE'];
		$this->sSystem_PHP_STR='PHP.'.PHP_VERSION;
		$this->sSystem_MYSQL_STR='MYSQL.5.+';
		$this->sSystem_DiskSize_STR=intval(diskfreespace('.') / (1024 * 1024)).' MB';
		//$this->sSystem_UploadSize_STR=@ini_get(upload_max_filesize);
		//-- #News --
		$this->sNewsContent='';
		
	}
	public function OnNotes(){
		$tmpSQL=' SELECT A.onbtID,A.onbtName,A.onbtNameStyle,A.onbtCreateTime,B.onbctContent
			FROM {Nets.TableHead}oanotebook AS A
			INNER JOIN {Nets.TableHead}oanotebookcont AS B ON B.onbctIndexID=A.onbtID
			WHERE 1=1 AND A.onbtCreateBy={Nets.CreateBy}
			ORDER BY A.onbtOrderBy DESC,A.onbtID DESC LIMIT 0,5 ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.CreateBy}',$this->sUserInfo[0]['Columns']['uitID']['Value'],$tmpSTR);
		$this->sData_Notes=$this->sDb->Search($tmpSTR);
		
		
	}
	public function OnNews(){
		$tmpURL=$this->sysFileConfig['sysCoreAPISITE'].$this->sysFileConfig['sysCoreNewsURL'];
		$this->sNewsContent=$this->readURL($tmpURL);
		exit($this->sNewsContent);
		
		return 0;
	}
	public function OnPowerCheck(){
		$tmpData=array();
		$this->sApp_User->sSite=$this->sCode->URL_MakeParameter($this->sysPage,1);
		$tmpINT=$this->sApp_User->checkF23HFSSHVS12($tmpData);
		$this->sMessage='<span class="FStrong">您的授权号为：</span>{Nets.CODE}，您的授权号有效，授权号到期时间为：{Nets.Time}；<a href="{Nets.PHost}" class="Link4 FBlue3" target="_blank">到官方网站上了解更多内容...</a>';
		if ($tmpINT!=0) {
			//ERROR
			$this->sMessage='<span class="FStrong FRed3">您的授权号为：</span><span class="FRed3">{Nets.CODE}，授权号无效或已到期或网站名称与授权名称不一致，您的系统将最多只能建立{Nets.Usercount}个用户；</span><br />
				<a href="{Nets.PHost}" class="Link4 FBlue3" target="_blank">1.请到官方网站上注册授权号以解除所有限制</a>
				<a href="../../../{Nets.Path}m_nets/System/sysConfigBusiness.php" class="Link4 FBlue3" target="_blank">2.填写已获得的授权号</a>
				<a href="{Nets.PHost}" class="Link4 FBlue3" target="_blank">3.到官方网站上了解更多内容...</a>';
		}
		$this->sMessage=str_replace('{Nets.CODE}',$this->sysFileConfig['sysCorePowerNumcode'],$this->sMessage);
		$this->sMessage=str_replace('{Nets.Time}',$tmpData['Time_End'],$this->sMessage);
		$this->sMessage=str_replace('{Nets.PHost}',$this->sysFileConfig['sysCoreAPISITE'],$this->sMessage);
		$this->sMessage=str_replace('{Nets.Usercount}',$this->sApp_User->sKASDJI83VKJSDFKJSD,$this->sMessage);
		$this->sMessage=str_replace('{Nets.Path}',$this->sPATH,$this->sMessage);
		
		
		return 0;
	}
	
	
}
//-- ------ #Instanct ------
$tmpDefault=new PaDefault();
$tmpComHead->sMenuid=100;
$tmpDefault->OnPage();
$tmpDefault->sysMetaTitle=$tmpDefault->sMetaTitle.' - '.$tmpDefault->sysFileConfig['sysTitle'];
if($tmpDefault->sActionType=='DGetNotes' || $tmpDefault->sActionType=='DGetNews'){
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/Head_1.php');
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysManaTemplatePath.'Nets/Data_Main.php');
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/End_1.php');
}else if($tmpDefault->sActionType=='DAdd_Get'){
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/Head_1.php');
	require($netsFileConfig['sysCoreRoot'].'Template/Mana/m_default/Template/Message_Info.php');
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/End_1.php');
}else if($tmpDefault->sActionType=='DPowerCheck'){
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/Head_1.php');
	require($netsFileConfig['sysCoreRoot'].'Template/Mana/m_default/Template/Message_Info.php');
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/End_1.php');
	
}else {
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/Head_0.php');
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysManaTemplatePath.'Template/main.php');
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/End_0.php');
} ?>