<?php
header("Content-type: text/html; charset=utf-8");
require( '../../../../init.php' );
require('./function.php');
require('./lib/accountIdcsmart.php');

if(!_requsetMethod("post")){
	_json(["ststus"=>400,"msg"=>"请求类型只能是post"]); 
}

list($module,$action)=explode("_",_httpRequest("get","action"));
if($module!='product'){
	$_httpHeader=_httpHeader();
	$account=new accountIdcsmart();
	$accountResult=$account->checkAccount($_httpHeader);
	if($accountResult['status']!=200 || empty(_httpRequest("get","action"))){
		unset($accountResult['data']);
		_json($accountResult); 
	}
}

$module=$module."Idcsmart";
if($module=="accountIdcsmart"){
	_json(["ststus"=>400,"msg"=>"error!"]); 
}
$lib='./lib/'.$module.'.php';
$file_lib=file_exists($lib);


if($file_lib){
	require($lib);
	$file_module=class_exists($module);
	if($file_module){
		$newmodule=new $module();
		if($module=='serviceIdcsmart' && !in_array($action, ['create','suspend','unsuspend','terminate','changePassword'])){
			$file_action=method_exists($newmodule,'custom');
		}else{
			$file_action=method_exists($newmodule,$action);
		}
		
	}	
} 
if($file_action){
	$post=_httpRequest('post');
	if(!is_array($post)) $post=[];
	$post['account']=$accountResult['account'];
	if($module=='serviceIdcsmart' && !in_array($action, ['create','suspend','unsuspend','terminate','changePassword'])){
		$post['action']=$action;
		_json($newmodule->custom($post));
	}else{
		_json($newmodule->$action($post));
	}
	
}else{
	_json(["ststus"=>400,"msg"=>"error!!!"]); 
}
 



